<commit_before>
#include "../../Flare.h"
#include "../../Player/FlareHUD.h"
#include "FlareContextMenu.h"

#define LOCTEXT_NAMESPACE "FlareContextMenu"


/*----------------------------------------------------
	Construct
----------------------------------------------------*/

void SFlareContextMenu::Construct(const FArguments& InArgs)
{
	// Data
	Visible = false;
	OwnerHUD = InArgs._OwnerHUD;
	AFlarePlayerController* PC = Cast<AFlarePlayerController>(OwnerHUD->GetOwner());
	const FFlareContainerStyle* ContainerStyle = &FFlareStyleSet::Get().GetWidgetStyle<FFlareContainerStyle>("/Style/NoContainerStyle");
	const FTextBlockStyle* TextStyle = &FFlareStyleSet::Get().GetWidgetStyle<FTextBlockStyle>("Flare.Title1Inverted");

	// Structure
	ChildSlot
	.HAlign(HAlign_Left)
	.VAlign(VAlign_Top)
	[
		SNew(SBorder)
		.BorderImage(FCoreStyle::Get().GetBrush("NoBrush"))
		.Padding(this, &SFlareContextMenu::GetContextMenuPosition)
		[
			SAssignNew(Container, SVerticalBox)

			+ SVerticalBox::Slot()
			.AutoHeight()
			[
				SNew(SHorizontalBox)

				// Legend
				+ SHorizontalBox::Slot()
				.AutoWidth()
				[
					SAssignNew(MinimizedButton, SFlareButton)
					.ContainerStyle(ContainerStyle)
					.OnClicked(this, &SFlareContextMenu::Open)
					.ButtonStyle(FFlareStyleSet::Get(), "/Style/ContextMenuButton")
				]

				// Menu
				+ SHorizontalBox::Slot()
				.AutoWidth()
				[
					SAssignNew(ActionMenu, SFlareTargetActions).Player(PC)
				]
			]
		]
	];

	// Legend
	MinimizedButton->GetContainer()->SetContent(
		SNew(SBorder)
		.BorderImage(FFlareStyleSet::GetIcon("DesignatorContextButton"))
		.Padding(FMargin(31, 11))
		[
			SNew(STextBlock)
			.Text(this, &SFlareContextMenu::GetLegendText)
			.TextStyle(TextStyle)
		]
	);
}


/*----------------------------------------------------
	Interaction
----------------------------------------------------*/

void SFlareContextMenu::SetStation(IFlareStationInterface* Target)
{
	ActionMenu->SetStation(Target);
}

void SFlareContextMenu::SetShip(IFlareShipInterface* Target)
{
	ActionMenu->SetShip(Target);
}

void SFlareContextMenu::Show()
{
	Close();
	Visible = true;
	SetVisibility(EVisibility::Visible);
}

void SFlareContextMenu::Hide()
{
	Close();
	Visible = false;
	SetVisibility(EVisibility::Hidden);
}<commit_msg>Cleaner code<commit_after>
#include "../../Flare.h"
#include "../../Player/FlareHUD.h"
#include "FlareContextMenu.h"

#define LOCTEXT_NAMESPACE "FlareContextMenu"


/*----------------------------------------------------
	Construct
----------------------------------------------------*/

void SFlareContextMenu::Construct(const FArguments& InArgs)
{
	// Data
	Visible = false;
	OwnerHUD = InArgs._OwnerHUD;
	AFlarePlayerController* PC = Cast<AFlarePlayerController>(OwnerHUD->GetOwner());
	const FFlareContainerStyle* ContainerStyle = &FFlareStyleSet::Get().GetWidgetStyle<FFlareContainerStyle>("/Style/ContextMenuButtonStyle");
	const FTextBlockStyle* TextStyle = &FFlareStyleSet::Get().GetWidgetStyle<FTextBlockStyle>("Flare.Title1Inverted");

	// Structure
	ChildSlot
	.HAlign(HAlign_Left)
	.VAlign(VAlign_Top)
	[
		SNew(SBorder)
		.BorderImage(FCoreStyle::Get().GetBrush("NoBrush"))
		.Padding(this, &SFlareContextMenu::GetContextMenuPosition)
		[
			SAssignNew(Container, SVerticalBox)

			+ SVerticalBox::Slot()
			.AutoHeight()
			[
				SNew(SHorizontalBox)

				// Legend
				+ SHorizontalBox::Slot()
				.AutoWidth()
				[
					SAssignNew(MinimizedButton, SFlareButton)
					.ContainerStyle(ContainerStyle)
					.OnClicked(this, &SFlareContextMenu::Open)
					.ButtonStyle(FFlareStyleSet::Get(), "/Style/ContextMenuButton")
				]

				// Menu
				+ SHorizontalBox::Slot()
				.AutoWidth()
				[
					SAssignNew(ActionMenu, SFlareTargetActions).Player(PC)
				]
			]
		]
	];

	// Legend
	MinimizedButton->GetContainer()->SetContent(
		SNew(STextBlock)
		.Text(this, &SFlareContextMenu::GetLegendText)
		.TextStyle(TextStyle)
	);
}


/*----------------------------------------------------
	Interaction
----------------------------------------------------*/

void SFlareContextMenu::SetStation(IFlareStationInterface* Target)
{
	ActionMenu->SetStation(Target);
}

void SFlareContextMenu::SetShip(IFlareShipInterface* Target)
{
	ActionMenu->SetShip(Target);
}

void SFlareContextMenu::Show()
{
	Close();
	Visible = true;
	SetVisibility(EVisibility::Visible);
}

void SFlareContextMenu::Hide()
{
	Close();
	Visible = false;
	SetVisibility(EVisibility::Hidden);
}
{'fraction_non_alphanumeric': 0.2237463458511356, 'fraction_numerical': 0.0013492241960872497, 'mean_word_length': 3.1071098799630654, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2638382', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1438, 'n_words': 177}