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

Bounty Contracts #56

Merged
merged 28 commits into from
Jul 23, 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
7 changes: 7 additions & 0 deletions Content.Client/_NF/BountyContracts/BountyContractSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared._NF.BountyContracts;

namespace Content.Client._NF.BountyContracts;

public sealed class BountyContractSystem : SharedBountyContractSystem
{
}
100 changes: 100 additions & 0 deletions Content.Client/_NF/BountyContracts/UI/BountyContractUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using Content.Client.UserInterface.Fragments;
using Content.Shared._NF.BountyContracts;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;

namespace Content.Client._NF.BountyContracts.UI;

[UsedImplicitly]
public sealed class BountyContractUi : UIFragment
{
private BountyContractUiFragment? _fragment;
private BoundUserInterface? _userInterface;

public override Control GetUIFragmentRoot()
{
return _fragment!;
}

public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
{
_fragment = new BountyContractUiFragment();
_userInterface = userInterface;
}


public override void UpdateState(BoundUserInterfaceState state)
{
if (_fragment == null)
return;

if (state is BountyContractListUiState listState)
{
ShowListState(listState);
}
else if (state is BountyContractCreateUiState createState)
{
ShowCreateState(createState);
}
}

private void UnloadPreviousState()
{
_fragment?.RemoveAllChildren();
}

private void ShowCreateState(BountyContractCreateUiState state)
{
UnloadPreviousState();

var create = new BountyContractUiFragmentCreate();
create.OnCancelPressed += OnCancelCreatePressed;
create.OnCreatePressed += OnTryCreatePressed;

create.SetPossibleTargets(state.Targets);
create.SetVessels(state.Vessels);

_fragment?.AddChild(create);
}

private void ShowListState(BountyContractListUiState state)
{
UnloadPreviousState();

var list = new BountyContractUiFragmentList();
list.OnCreateButtonPressed += OnOpenCreateUiPressed;
list.OnRefreshButtonPressed += OnRefreshListPressed;
list.OnRemoveButtonPressed += OnRemovePressed;

list.SetContracts(state.Contracts, state.IsAllowedRemoveBounties);
list.SetCanCreate(state.IsAllowedCreateBounties);

_fragment?.AddChild(list);
}

private void OnRemovePressed(BountyContract obj)
{
_userInterface?.SendMessage(new BountyContractTryRemoveUiMsg(obj.ContractId));
}

private void OnRefreshListPressed()
{
_userInterface?.SendMessage(new BountyContractRefreshListUiMsg());
}

private void OnOpenCreateUiPressed()
{
_userInterface?.SendMessage(new BountyContractOpenCreateUiMsg());
}

private void OnCancelCreatePressed()
{
_userInterface?.SendMessage(new BountyContractCloseCreateUiMsg());
}

private void OnTryCreatePressed(BountyContractRequest contract)
{
_userInterface?.SendMessage(new BountyContractTryCreateMsg(contract));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- Bounty Contracts Cartridge UI -->
<ui:BountyContractUiFragment xmlns:ui="clr-namespace:Content.Client._NF.BountyContracts.UI"
xmlns="https://spacestation14.io"
VerticalExpand="True" HorizontalExpand="True">

<!-- All submenus are added by code -->

</ui:BountyContractUiFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;

namespace Content.Client._NF.BountyContracts.UI;

[GenerateTypedNameReferences]
public sealed partial class BountyContractUiFragment : BoxContainer
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!-- Create new bounty -->
<Control xmlns="https://spacestation14.io" HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">

<!-- New Contract Details -->
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<BoxContainer Orientation="Horizontal" Margin="4,4,4,4">
<Label Text="{Loc 'bounty-contracts-ui-create-name'}" MinWidth="80"/>
<OptionButton Name="NameSelector" HorizontalExpand="True"/>
<LineEdit Name="NameEdit" PlaceHolder="{Loc 'bounty-contracts-ui-create-name-placeholder'}"
HorizontalExpand="True" Visible="False"/>
<Control MinSize="8 0" />
<Button Name="CustomNameButton" Text="{Loc 'bounty-contracts-ui-create-custom'}"
ToggleMode="True"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="4,4,4,4">
<Label Text="{Loc 'bounty-contracts-ui-create-dna'}" MinWidth="80"/>
<Label Name="DnaLabel" Text="{Loc 'bounty-contracts-ui-create-dna-unknown'}"
HorizontalExpand="True"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="4,4,4,4">
<Label Text="{Loc 'bounty-contracts-ui-create-vessel'}" MinWidth="80"/>
<OptionButton Name="VeselSelector" HorizontalExpand="True"/>
<LineEdit Name="VeselEdit" PlaceHolder="{Loc 'bounty-contracts-ui-create-vessel-placeholder'}"
HorizontalExpand="True" Visible="False"/>
<Control MinSize="8 0" />
<Button Name="CustomVeselButton" Text="{Loc 'bounty-contracts-ui-create-custom'}"
ToggleMode="True"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="4,4,4,4">
<Label Text="{Loc 'bounty-contracts-ui-create-reward'}" MinWidth="80"/>
<LineEdit Name="RewardEdit" MinWidth="80"/>
<Control MinSize="8 0" />
<Label Text="{Loc 'bounty-contracts-ui-create-reward-currency'}"/>
</BoxContainer>
<BoxContainer Orientation="Vertical" Margin="4,4,4,4"
VerticalExpand="True" >
<Label Text="{Loc 'bounty-contracts-ui-create-description'}"/>
<PanelContainer StyleClasses="LowDivider" />
<TextEdit Name="DescriptionEdit" MinHeight="64"/>
<PanelContainer StyleClasses="LowDivider" />
</BoxContainer>
<RichTextLabel Name="DisclaimerLabel" Margin="4,4,4,4"
HorizontalExpand="True"/>
</BoxContainer>

<!-- Footer -->
<BoxContainer Orientation="Horizontal" HorizontalExpand="True"
VerticalAlignment="Bottom"
Margin="8,8,8,8">
<Button Name="CancelButton" Text="{Loc 'bounty-contracts-ui-create-button-cancel'}"
HorizontalAlignment="Left"/>
<Control HorizontalExpand="True"/>
<Button Name="CreateButton" Text="{Loc 'bounty-contracts-ui-create-button-create'}"
Disabled="True"
HorizontalAlignment="Right"/>
</BoxContainer>
</BoxContainer>

</Control>
Loading
Loading