Skip to content
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
28 changes: 2 additions & 26 deletions Content.Client/ADT/CharecterFlavor/CharacterFlavorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@
Margin="0 10 0 0">

<!-- CUSTOM SPECIES -->
<PanelContainer HorizontalExpand="True" VerticalExpand="True" SetWidth="275" >
<PanelContainer HorizontalExpand="True" VerticalExpand="True" >
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1a1a1a"/>
</PanelContainer.PanelOverride>

<BoxContainer Orientation="Vertical" Margin="8" SetWidth="250">
<BoxContainer Orientation="Vertical" Margin="8">
<ui:Label Name="CustomSpeciesTitle"
Text="{Loc 'flavor-interface-custom-species'}"
StyleClasses="LabelHeading"
Expand All @@ -108,30 +108,6 @@
</BoxContainer>
</PanelContainer>

<!-- OOC NOTES -->
<PanelContainer HorizontalExpand="True" VerticalExpand="True" SizeFlagsStretchRatio="3" >
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1a1a1a"/>
</PanelContainer.PanelOverride>

<BoxContainer Orientation="Vertical" Margin="8">
<ui:Label Text="{Loc 'flavor-interface-OOC-notes'}"
StyleClasses="LabelHeading"
Margin="8 0"/>

<ScrollContainer VerticalExpand="True"
HorizontalExpand="True"
VScrollEnabled="True"
HScrollEnabled="False">
<ui:RichTextLabel Name="OOCNotesLabel"
HorizontalExpand="True"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Margin="8"/>
</ScrollContainer>
</BoxContainer>
</PanelContainer>

</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void SetEntity(EntityUid uid)

Title = metaData.EntityName;
FlavorTextLabel.SetMarkup(flavor.FlavorText);
OOCNotesLabel.SetMarkup(flavor.OOCNotes);
}

public void SetHeadshot(byte[] image)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<BoxContainer xmlns="https://spacestation14.io" Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<Control HorizontalExpand="True" VerticalExpand="True" HorizontalAlignment="Stretch">
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Name="RulesContainer" VerticalExpand="True" Margin="0 0 5 0"/>
</ScrollContainer>
</Control>
</BoxContainer>
32 changes: 32 additions & 0 deletions Content.Client/ADT/FlavorText/Rules/FlavorTextRulesControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Content.Client.Guidebook;
using Content.Client.Guidebook.RichText;
using Content.Shared.Guidebook;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;

namespace Content.Client.ADT.FlavorText.Rules;

[GenerateTypedNameReferences]
public sealed partial class FlavorTextRulesControl : BoxContainer
{
[Dependency] private readonly DocumentParsingManager _parsingMan = default!;

public FlavorTextRulesControl()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

SetGuide();
}

private void SetGuide(ProtoId<GuideEntryPrototype>? entry = null)
{
entry ??= new ProtoId<GuideEntryPrototype>("FlavorTextRules");

Scroll.SetScrollValue(default);
RulesContainer.Children.Clear();
_parsingMan.TryAddMarkup(RulesContainer, entry.Value);
}
}
24 changes: 24 additions & 0 deletions Content.Client/ADT/FlavorText/Rules/FlavorTextRulesPopup.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Control xmlns="https://spacestation14.io"
xmlns:parallax="clr-namespace:Content.Client.Parallax"
xmlns:rules="clr-namespace:Content.Client.ADT.FlavorText.Rules"
VerticalExpand="True" HorizontalExpand="True"
MouseFilter="Stop">
<parallax:ParallaxControl SpeedX="20"/>
<Control VerticalExpand="True"
MaxWidth="800"
MaxHeight="900">
<PanelContainer StyleClasses="windowPanel" />
<BoxContainer Orientation="Vertical" SeparationOverride="10" Margin="10 10 5 10">
<rules:FlavorTextRulesControl/>
<Label Name="WaitLabel" />
<BoxContainer Orientation="Horizontal">
<Button Name="AcceptButton"
Text="{Loc 'flavor-rules-accept'}"
Disabled="True" />
<Button Name="CancelButton"
StyleClasses="negative"
Text="{Loc 'flavor-rules-cancel'}" />
</BoxContainer>
</BoxContainer>
</Control>
</Control>
64 changes: 64 additions & 0 deletions Content.Client/ADT/FlavorText/Rules/FlavorTextRulesPopup.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;

namespace Content.Client.ADT.FlavorText.Rules;

[GenerateTypedNameReferences]
public sealed partial class FlavorTextRulesPopup : Control
{
private float _timer;

public float Timer
{
get => _timer;
set
{
WaitLabel.Text = Loc.GetString("flavor-rules-wait", ("time", MathF.Floor(value)));
_timer = value;
}
}

public event Action? OnCancelPressed;
public event Action? OnAcceptPressed;

public FlavorTextRulesPopup()
{
RobustXamlLoader.Load(this);

AcceptButton.OnPressed += OnAcceptButtonPressed;
CancelButton.OnPressed += OnCancelButtonPressed;
}

private void OnCancelButtonPressed(BaseButton.ButtonEventArgs obj)
{
OnCancelPressed?.Invoke();
}

private void OnAcceptButtonPressed(BaseButton.ButtonEventArgs obj)
{
OnAcceptPressed?.Invoke();
}

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

if (!AcceptButton.Disabled)
return;

if (Timer > 0.0)
{
if (Timer - args.DeltaSeconds < 0)
Timer = 0;
else
Timer -= args.DeltaSeconds;
}
else
{
AcceptButton.Disabled = false;
}
}
}
36 changes: 20 additions & 16 deletions Content.Client/FlavorText/FlavorText.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,44 @@
VerticalExpand="True"
SeparationOverride="10">

<!-- Flavor Text Section -->
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
<PanelContainer HorizontalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#2d2d2d"/>
</PanelContainer.PanelOverride>

<BoxContainer Orientation="Vertical" Margin="10">
<Button Name="PreviewButton" Text="{Loc 'flavor-interface-prewiev'}" />
<ui:Label Text="{Loc 'flavor-interface-flavor-text-title'}"
<ui:Label Text="{Loc 'flavor-interface-rules-title'}"
Margin="0 0 0 8"
StyleClasses="LabelHeading"/>

<TextEdit Name="CFlavorTextInput"
Access="Public"
MinSize="220 100"
HorizontalExpand="True"
VerticalExpand="True"/>
<BoxContainer Orientation="Horizontal">
<Button Name="RulesButton"
Text="{Loc 'flavor-interface-rules-button'}"
HorizontalExpand="True"/>
<ui:Label Name="RulesStatusLabel"
Text="{Loc 'flavor-interface-rules-not-accepted'}"
HorizontalExpand="True"
HorizontalAlignment="Right"/>
</BoxContainer>
</BoxContainer>
</PanelContainer>

<!-- OOC Notes Section -->
<!-- Flavor Text Section -->
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#2d2d2d"/>
</PanelContainer.PanelOverride>

<BoxContainer Orientation="Vertical" Margin="10">
<ui:Label Text="{Loc 'flavor-interface-OOC-notes'}"
<Button Name="PreviewButton" Text="{Loc 'flavor-interface-prewiev'}" />
<ui:Label Text="{Loc 'flavor-interface-flavor-text-title'}"
Margin="0 0 0 8"
StyleClasses="LabelHeading"/>

<TextEdit Name="COOCTextInput"
<TextEdit Name="CFlavorTextInput"
Access="Public"
MinSize="220 100"
HorizontalExpand="True"
VerticalExpand="True"/>
VerticalExpand="True"
Editable="False"/>
</BoxContainer>
</PanelContainer>

Expand All @@ -61,7 +64,8 @@
Access="Public"
HorizontalExpand="True"
PlaceHolder="Вставьте сюда ссылку"
MinSize="0 30"/>
MinSize="0 30"
Editable="False"/>
</BoxContainer>
</PanelContainer>
</BoxContainer>
Expand Down
89 changes: 82 additions & 7 deletions Content.Client/FlavorText/FlavorText.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,53 +1,128 @@
// ADT-Tweak: Если что изменена структура этого файла
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
using Content.Client.ADT.FlavorText.Rules;

namespace Content.Client.FlavorText;

[GenerateTypedNameReferences]
public sealed partial class FlavorText : Control
{
public Action<string>? OnFlavorTextChanged;
public Action<string>? OnOOCNotesChanged;
public Action<string>? OnHeadshotUrlChanged;
public Action? OnPreviewRequested;

// ADT-Tweak-start
private bool _rulesAccepted;
private FlavorTextRulesPopup? _rulesPopup;
private string _rulesAcceptedText = string.Empty;
private string _rulesNotAcceptedText = string.Empty;
// ADT-Tweak-end

public FlavorText()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

var loc = IoCManager.Resolve<ILocalizationManager>();
CFlavorTextInput.Placeholder = new Rope.Leaf(loc.GetString("flavor-text-placeholder"));

_rulesAcceptedText = Loc.GetString("flavor-interface-rules-accepted");
_rulesNotAcceptedText = Loc.GetString("flavor-interface-rules-not-accepted");

RulesButton.OnPressed += _ => OpenRulesPopup(); // ADT-Tweak

CFlavorTextInput.OnTextChanged += _ => FlavorTextChanged();

// ADT-Tweak-start
COOCTextInput.OnTextChanged += _ => OOCNotesChanged();
CHeadshotUrlInput.OnTextChanged += _ => HeadshotUrlChanged();
PreviewButton.OnPressed += _ => PreviewRequested();

UpdateControlsState();
}

private void OpenRulesPopup()
{
if (_rulesPopup != null)
return;

_rulesPopup = new FlavorTextRulesPopup
{
Timer = 5f
};

_rulesPopup.OnAcceptPressed += OnRulesAccepted;
_rulesPopup.OnCancelPressed += OnRulesPopupClosed;

var uiManager = IoCManager.Resolve<IUserInterfaceManager>();
uiManager.WindowRoot.AddChild(_rulesPopup);
LayoutContainer.SetAnchorPreset(_rulesPopup, LayoutContainer.LayoutPreset.Wide);
}

private void OnRulesAccepted()
{
_rulesAccepted = true;
UpdateControlsState();
CloseRulesPopup();
}

private void OnRulesPopupClosed()
{
CloseRulesPopup();
}

private void CloseRulesPopup()
{
if (_rulesPopup == null)
return;

_rulesPopup.OnAcceptPressed -= OnRulesAccepted;
_rulesPopup.OnCancelPressed -= OnRulesPopupClosed;

_rulesPopup.Orphan();
_rulesPopup = null;
}

private void UpdateControlsState()
{
CFlavorTextInput.Editable = _rulesAccepted;
CHeadshotUrlInput.Editable = _rulesAccepted;
PreviewButton.Disabled = !_rulesAccepted;

RulesStatusLabel.Text = _rulesAccepted
? _rulesAcceptedText
: _rulesNotAcceptedText;
// ADT-Tweak-end
}

public void FlavorTextChanged()
{
// ADT-Tweak-start
if (!_rulesAccepted)
return;
// ADT-Tweak-end

OnFlavorTextChanged?.Invoke(Rope.Collapse(CFlavorTextInput.TextRope).Trim());
}

// ADT-Tweak-start
public void OOCNotesChanged()
{
OnOOCNotesChanged?.Invoke(Rope.Collapse(COOCTextInput.TextRope).Trim());
}

public void HeadshotUrlChanged()
{
if (!_rulesAccepted)
return;

OnHeadshotUrlChanged?.Invoke(CHeadshotUrlInput.Text.Trim());
}

private void PreviewRequested()
{
if (!_rulesAccepted)
return;

OnPreviewRequested?.Invoke();
}
// ADT-Tweak-end
Expand Down
Loading
Loading