Skip to content

Commit

Permalink
Обновление спонсорской системы (#905)
Browse files Browse the repository at this point in the history
* Апдейт спонсорки

* Доработка апдейта

* упс
  • Loading branch information
VigersRay authored Dec 23, 2024
1 parent 1da8f17 commit b56448c
Show file tree
Hide file tree
Showing 76 changed files with 1,703 additions and 269 deletions.
3 changes: 2 additions & 1 deletion Content.Client/Humanoid/HumanoidAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ private void RemoveMarking(Marking marking, SpriteComponent spriteComp)
spriteComp.RemoveLayer(index);
}
}
private void ApplyMarking(MarkingPrototype markingPrototype,
// Sunrsie-Edit
public void ApplyMarking(MarkingPrototype markingPrototype,
IReadOnlyList<Color>? colors,
bool visible,
HumanoidAppearanceComponent humanoid,
Expand Down
51 changes: 51 additions & 0 deletions Content.Client/_Sunrise/GhostTheme/GhostThemeBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using Content.Shared._Sunrise.GhostTheme;
using JetBrains.Annotations;

namespace Content.Client._Sunrise.GhostTheme;

[UsedImplicitly]
public sealed class GhostThemeBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GhostThemeMenu? _menu;

public GhostThemeBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_menu = new GhostThemeMenu();
_menu.OnClose += Close;
_menu.OnIdSelected += OnIdSelected;
_menu.OpenCentered();
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not GhostThemeBoundUserInterfaceState st)
return;

_menu?.UpdateState(st.GhostThemes);
}

private void OnIdSelected(string selectedId)
{
SendMessage(new GhostThemePrototypeSelectedMessage(selectedId));
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (disposing)
{
_menu?.Close();
_menu = null;
}
}
}
11 changes: 11 additions & 0 deletions Content.Client/_Sunrise/GhostTheme/GhostThemeMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ghost-theme-menu-title'}"
MinSize="612 612"
Resizable="False">
<BoxContainer Orientation="Vertical">
<ScrollContainer VerticalExpand="True">
<GridContainer Name="Grid" Columns="4" Margin="0 5" >
</GridContainer>
</ScrollContainer>
</BoxContainer>
</DefaultWindow>
76 changes: 76 additions & 0 deletions Content.Client/_Sunrise/GhostTheme/GhostThemeMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using System.Numerics;
using Content.Client.Stylesheets;
using Content.Shared._Sunrise.GhostTheme;
using Content.Shared._Sunrise.SunriseCCVars;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;

namespace Content.Client._Sunrise.GhostTheme;

[GenerateTypedNameReferences]
public sealed partial class GhostThemeMenu : DefaultWindow
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

public event Action<string>? OnIdSelected;

private List<string> _availableGhostThemes = [];

public GhostThemeMenu()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
}

public void UpdateState(List<string> ghostThemes)
{
_availableGhostThemes = ghostThemes;
UpdateGrid();
}

private void UpdateGrid()
{
ClearGrid();

foreach (var ghostTheme in _availableGhostThemes)
{
if (!_prototypeManager.TryIndex(ghostTheme, out GhostThemePrototype? ghostThemePrototype))
continue;

var button = new Button
{
SetSize = new Vector2(128, 128),
HorizontalExpand = true,
ToggleMode = false,
StyleClasses = {StyleBase.ButtonSquare},
};
button.OnPressed += _ =>
{
OnIdSelected?.Invoke(ghostTheme);
_cfg.SetCVar(SunriseCCVars.SponsorGhostTheme, ghostTheme);
_cfg.SaveToFile();
};
Grid.AddChild(button);

var ghost = new TextureRect()
{
Texture = ghostThemePrototype.Sprite.Frame0(),
Stretch = TextureRect.StretchMode.KeepAspectCentered,
};

button.AddChild(ghost);
}
}

private void ClearGrid()
{
Grid.RemoveAllChildren();
}
}
24 changes: 16 additions & 8 deletions Content.Client/_Sunrise/GhostTheme/GhostThemeSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using Content.Shared._Sunrise.GhostTheme;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;

Expand All @@ -7,6 +9,7 @@ namespace Content.Client._Sunrise.GhostTheme;
public sealed class GhostThemeSystem: EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

public override void Initialize()
{
base.Initialize();
Expand All @@ -17,16 +20,21 @@ private void OnInit(EntityUid uid, GhostThemeComponent component, ref AfterAutoH
{
if (component.GhostTheme == null
|| !_prototypeManager.TryIndex<GhostThemePrototype>(component.GhostTheme, out var ghostThemePrototype))
{
return;
}
foreach (var entry in ghostThemePrototype.Components.Values)

if (!EntityManager.TryGetComponent<SpriteComponent>(uid, out var sprite))
return;

if (!sprite.LayerMapTryGet(EffectLayers.Unshaded, out var layer))
{
if (entry.Component is not SpriteComponent spriteComponent ||
!EntityManager.TryGetComponent<SpriteComponent>(uid, out var targetsprite))
continue;
targetsprite.CopyFrom(spriteComponent);
targetsprite.LayerSetShader(0, "unshaded");
sprite.LayerSetSprite(layer, ghostThemePrototype.Sprite);
sprite.LayerSetShader(layer, "unshaded");
sprite.LayerSetColor(layer, ghostThemePrototype.SpriteColor);
sprite.LayerSetScale(layer, ghostThemePrototype.Scale);
}

sprite.DrawDepth = DrawDepth.Default + 11;
sprite.OverrideContainerOcclusion = true;
sprite.NoRotation = true;
}
}
2 changes: 1 addition & 1 deletion Content.Client/_Sunrise/Roadmap/RoadmapUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void OnStateEntered(LobbyState state)
if (_shown || _window != null)
return;

ToggleRoadmap();
//ToggleRoadmap();
}

public void ToggleRoadmap()
Expand Down
134 changes: 134 additions & 0 deletions Content.Client/_Sunrise/SponsorTiers/SponsorTierEntry.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<Control xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Name="BackgroundColorPanel"
MouseFilter="Pass">
<ScrollContainer HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Orientation="Vertical" VerticalExpand="True" VerticalAlignment="Stretch">
<BoxContainer Orientation="Vertical" Name="EntryContent" VerticalExpand="True"
HorizontalAlignment="Stretch" VerticalAlignment="Top" Access="Public" >
<!-- Информация -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-entry-info'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 5 0 0">
<Label Name="TierTitle" Text="{Loc 'sponsor-tiers-gui-tier'}" StyleClasses="LabelKeyText" Margin="0 0 5 0" />
<Label Name="TierLabel"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 5 0 0">
<Label Name="OocColorTitle" Text="{Loc 'sponsor-tiers-gui-ooc-color'}" StyleClasses="LabelKeyText" Margin="0 0 5 0" />
<Label Name="OocColorLabel"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 5 0 0">
<Label Name="ExtraSlotsTitle" Text="{Loc 'sponsor-tiers-gui-extra-slots'}" StyleClasses="LabelKeyText" Margin="0 0 5 0" />
<Label Name="ExtraSlotsLabel"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 5 0 0">
<Label Name="PriorityJoinTitle" Text="{Loc 'sponsor-tiers-gui-priority-join'}" StyleClasses="LabelKeyText" Margin="0 0 5 0" />
<Label Name="PriorityJoinLabel"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 5 0 0">
<Label Name="AllowedRespawnTitle" Text="{Loc 'sponsor-tiers-gui-allowed-respawn'}" StyleClasses="LabelKeyText" Margin="0 0 5 0" />
<Label Name="AllowedRespawnLabel"/>
</BoxContainer>
<!-- TTS голоса -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-tts-voices'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-tts-voices-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="TTSVoicesGrid" Columns="4" Margin="0 5" />
<!-- Открытие рас -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-allowed-species'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-allowed-species-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="AllowedSpeciesGrid" Columns="6" Margin="0 5" />
<!-- Открытие антагов -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-open-antags'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-open-antags-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="OpenAntagGrid" Columns="6" Margin="0 5" />
<!-- Приоритет антагов -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-priority-antags'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-priority-antags-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="PriorityAntagGrid" Columns="6" Margin="0 5" />
<!-- Открытие ролей призраков -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-open-ghost-roles'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-open-ghost-roles-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="OpenGhostRolesGrid" Columns="6" Margin="0 5" />
<!-- Приоритет ролей призраков -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-priority-ghost-roles'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-priority-ghost-roles-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="PriorityGhostRolesGrid" Columns="6" Margin="0 5" />
<!-- Открытие ролей -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-open-roles'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-open-roles-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="OpenRolesGrid" Columns="6" Margin="0 5" />
<!-- Приоритет ролей -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-priority-roles'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-priority-roles-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="PriorityRolesGrid" Columns="6" Margin="0 5" />
<!-- Пропуск ролей -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-bypass-roles'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-bypass-roles-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="BypassRolesGrid" Columns="6" Margin="0 5" />
<!-- Кастомизация -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-allowed-markings'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-allowed-markings-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="AllowedMarkingsGrid" Columns="6" Margin="0 5" />
<!-- Лоадауты -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-allowed-loadouts'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-allowed-loadouts-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="AllowedLoadoutsGrid" Columns="6" Margin="0 5" />
<!-- Скины призрака -->
<BoxContainer Orientation="Horizontal" >
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
<Label Text="{Loc 'sponsor-tiers-gui-ghost-themes'}" StyleClasses="LabelKeyText"/>
<customControls:HSeparator Color="#4972A1" HorizontalExpand="True" MaxHeight="2" />
</BoxContainer>
<Label Text="{Loc 'sponsor-tiers-gui-ghost-themes-description'}" StyleClasses="LabelKeyText"/>
<GridContainer Name="GhostThemesGrid" Columns="6" Margin="0 5" />
</BoxContainer>
</BoxContainer>
</ScrollContainer>
</Control>
Loading

0 comments on commit b56448c

Please sign in to comment.