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

Admin "Add objective" button fix #568

Merged
merged 6 commits into from
Dec 10, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ public sealed class UICommandButton : CommandButton
public Type? WindowType { get; set; }
private DefaultWindow? _window;

public event Action<DefaultWindow>? OnWindowCreated;

protected override void Execute(ButtonEventArgs obj)
{
if (WindowType == null)
return;
_window = (DefaultWindow) IoCManager.Resolve<IDynamicTypeFactory>().CreateInstance(WindowType);
//SS220-antag-add-objective begin
if (_window is not null)
OnWindowCreated?.Invoke(_window);
//SS220-antag-add-objective end
_window?.OpenCentered();
}
}
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Administration/UI/Tabs/AdminTab/AdminTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:at="clr-namespace:Content.Client.Administration.UI.Tabs.AdminTab"
xmlns:SS220at="clr-namespace:Content.Client.SS220.Administration.UI.Tabs.AdminTab"
Margin="4"
MinSize="50 50">
<BoxContainer Orientation="Vertical">
Expand All @@ -17,7 +18,7 @@
<cc:UICommandButton Command="callshuttle" Text="{Loc admin-player-actions-window-shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
<cc:CommandButton Command="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}" />
<cc:CommandButton Command="faxui" Text="{Loc admin-player-actions-window-admin-fax}" />
<cc:UICommandButton Command="antagonists" Text="{Loc admin-player-actions-window-antagonists}" WindowType="{x:Type at:AntagonistsWindow}" />
<cc:UICommandButton Command="antagonists" Text="{Loc admin-player-actions-window-antagonists}" WindowType="{x:Type SS220at:AntagonistsWindow}" />
<cc:CommandButton Command="allttsqueuereset" Text="{Loc admin-player-actions-tts-queue-reset}" WithDialog="True" />
</GridContainer>
</BoxContainer>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt -->

<BoxContainer xmlns="https://spacestation14.io"
xmlns:controls="using:Content.Client.UserInterface.Controls"
Orientation="Vertical">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using System.Linq;
using Content.Client.Administration.Systems;
using Content.Client.UserInterface.Controls;
Expand All @@ -10,7 +12,7 @@
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;

namespace Content.Client.Administration.UI.CustomControls
namespace Content.Client.SS220.Administration.UI.CustomControls
{
[GenerateTypedNameReferences]
public sealed partial class AntagonistsListControl : BoxContainer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt -->

<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ui-add-objective-title'}"
Resizable="False">
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinSize="240 60">
<BoxContainer Orientation="Horizontal">
<LineEdit Name="ObjectiveLineEdit" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc 'ui-add-objective-line-edit-placeholder'}"/>
</BoxContainer>
<Button Name="ApplyButton" Access="Public" Text="{Loc 'ui-add-objective-apply'}"/>
</BoxContainer>
</DefaultWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Player;

namespace Content.Client.SS220.Administration.UI.Tabs.AdminTab;

[GenerateTypedNameReferences]
public partial class AddObjectiveWindow : DefaultWindow
{
private ICommonSession? _selectedAntagonist;
private string _input = "";

public AddObjectiveWindow()
{
RobustXamlLoader.Load(this);
}

protected override void EnteredTree()
{
ApplyButton.OnPressed += OnApplyButtonPressed;
ObjectiveLineEdit.OnTextChanged += OnObjectiveLineEditChanged;
}

public void SetAntagonist(ICommonSession antagonistPlayerName)
{
_selectedAntagonist = antagonistPlayerName;
}

private void OnObjectiveLineEditChanged(LineEdit.LineEditEventArgs args)
{
_input = args.Text;
}

private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
{
if (_input.Length == 0)
return;

IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addobjective {_selectedAntagonist} {_input}");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt -->

<DefaultWindow
xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:SS220cc="clr-namespace:Content.Client.SS220.Administration.UI.CustomControls"
xmlns:SS220at="clr-namespace:Content.Client.SS220.Administration.UI.Tabs.AdminTab"
Title="{Loc admin-player-actions-window-antagonists}" MinSize="425 272">
<BoxContainer Orientation="Vertical">
<SS220cc:AntagonistsListControl Name="AntagonistsList" VerticalExpand="True" />
<BoxContainer Orientation="Horizontal">
<Button Name="ListOfTargetsButton" Text="{Loc admin-antagonists-list-of-targets}" Disabled="True"/>
<cc:UICommandButton Name="AddTargetButton" Text="{Loc admin-antagonists-add-target}" Disabled="True" WindowType="{x:Type SS220at:AddObjectiveWindow}"/>
</BoxContainer>
</BoxContainer>
</DefaultWindow>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;

namespace Content.Client.Administration.UI.Tabs.AdminTab
namespace Content.Client.SS220.Administration.UI.Tabs.AdminTab
{
[GenerateTypedNameReferences]
[UsedImplicitly]
Expand All @@ -19,15 +22,16 @@ protected override void EnteredTree()
{
AntagonistsList.OnSelectionChanged += OnListOnOnSelectionChanged;
ListOfTargetsButton.OnPressed += ListOfTargetsButtonOnPressed;
AddTargetButton.OnPressed += AddTargetButtonOnPressed;
//AddTargetButton.OnPressed += AddTargetButtonOnPressed;
AddTargetButton.OnWindowCreated += AddTargetButtonOnWindowCreated;
}

private void OnListOnOnSelectionChanged(PlayerInfo? obj)
{
_selectedAntagonist = obj;
var disableButtons = _selectedAntagonist == null;
ListOfTargetsButton.Disabled = disableButtons;
//AddTargetButton.Disabled = disableButtons;
AddTargetButton.Disabled = disableButtons;
}

private void ListOfTargetsButtonOnPressed(BaseButton.ButtonEventArgs obj)
Expand All @@ -39,6 +43,16 @@ private void ListOfTargetsButtonOnPressed(BaseButton.ButtonEventArgs obj)
$"openobjectives {_selectedAntagonist.SessionId}");
}

private void AddTargetButtonOnWindowCreated(DefaultWindow window)
{
// This is dumb.
if (_selectedAntagonist is null)
return;
var addObjectiveWindow = (AddObjectiveWindow) window;
var antagSession = IoCManager.Resolve<IPlayerManager>().GetSessionById(_selectedAntagonist.SessionId);
addObjectiveWindow.SetAntagonist(antagSession);
}

private void AddTargetButtonOnPressed(BaseButton.ButtonEventArgs obj)
{
if (_selectedAntagonist == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ui-add-objective-title = Add objective
ui-add-objective-line-edit-placeholder = Objective prototype ID
ui-add-objective-apply = Confirm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ui-add-objective-title = Добавить цель
ui-add-objective-line-edit-placeholder = ID прототипа цели
ui-add-objective-apply = Добавить
Loading