<commit_before>// Copyright 2014 <NAME>. All Rights Reserved.

#include "VaQuoleUIPluginPrivatePCH.h"

AVaQuoleUIPlayerController::AVaQuoleUIPlayerController(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	bDebugMouseInput = false;
}

void AVaQuoleUIPlayerController::InitInputSystem()
{
	Super::InitInputSystem();

	BIND_ACTION(InputComponent, "MouseDown", IE_Pressed, &AVaQuoleUIPlayerController::MouseDown);
	BIND_ACTION(InputComponent, "MouseUp", IE_Released, &AVaQuoleUIPlayerController::MouseUp);
}

void AVaQuoleUIPlayerController::PlayerTick(float DeltaTime)
{
	Super::PlayerTick(DeltaTime);

	MouseEvent(EMouseEvent::MouseMove, VaQuole::EMouseButton::NoButton);
}

void AVaQuoleUIPlayerController::InputKeyQ(FViewport* Viewport, FKey Key, EInputEvent EventType, float AmountDepressed, bool bGamepad)
{
	FVector ActorImpact;
	UVaQuoleUIComponent* View;
	UStaticMeshComponent* Mesh;

	// Check we're targeting UI on scene
	if (GetTargetUIComponent(ActorImpact, &View, &Mesh))
	{
		View->InputKeyQ(Viewport, Key, EventType, AmountDepressed, bGamepad);
	}

	// Check we have HUD
	AVaQuoleHUD* MyHUD = GetVaQuoleHUD();
	if (MyHUD && MyHUD->VaQuoleUI.IsValid())
	{
		MyHUD->VaQuoleUI->InputKeyQ(Viewport, Key, EventType, AmountDepressed, bGamepad);
	}
}

void AVaQuoleUIPlayerController::MouseEvent(EMouseEvent::Type MouseEvent, VaQuole::EMouseButton::Type Button)
{
	FVector ActorImpact;
	UVaQuoleUIComponent* View;
	UStaticMeshComponent* Mesh;

	if (GetTargetUIComponent(ActorImpact, &View, &Mesh))
	{
		FVector Min, Max;

		Mesh->GetLocalBounds(Min, Max);

		if (bDebugMouseInput)
		{
			UE_LOG(LogVaQuole, Warning, TEXT("Min %s"), *Min.ToString());
			UE_LOG(LogVaQuole, Warning, TEXT("Max %s"), *Max.ToString());
		}

		// @TODO Add rotation modificator
		int32 X = View->GetWidth() * (ActorImpact.X - Min.X) / (Max.X - Min.X);
		int32 Y = View->GetHeight() * (Max.Z - ActorImpact.Z) / (Max.Z - Min.Z);

		switch (MouseEvent)
		{
		case EMouseEvent::MouseMove:
			View->MouseMove(X, Y);
			break;

		case EMouseEvent::MousePressed:
			View->MouseClick(X, Y, Button, true);
			break;

		case EMouseEvent::MouseReleased:
			View->MouseClick(X, Y, Button, false);
			break;

		default:
			break;
		}
	}
}


//////////////////////////////////////////////////////////////////////////
// Mouse input example

void AVaQuoleUIPlayerController::MouseDown()
{
	MouseEvent(EMouseEvent::MousePressed, VaQuole::EMouseButton::LeftButton);
}

void AVaQuoleUIPlayerController::MouseUp()
{
	MouseEvent(EMouseEvent::MouseReleased, VaQuole::EMouseButton::LeftButton);
}

void AVaQuoleUIPlayerController::EvalJS(FString ScriptSource)
{
	AVaQuoleHUD* MyHUD = GetVaQuoleHUD();
	if (MyHUD && MyHUD->VaQuoleUI.IsValid() && MyHUD->VaQuoleUI->GetUIWidget().IsValid())
	{
		MyHUD->VaQuoleUI->GetUIWidget()->EvaluateJavaScript(*ScriptSource);
	}
}


//////////////////////////////////////////////////////////////////////////<commit_msg>HUD input events<commit_after>// Copyright 2014 <NAME>. All Rights Reserved.

#include "VaQuoleUIPluginPrivatePCH.h"

AVaQuoleUIPlayerController::AVaQuoleUIPlayerController(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	bDebugMouseInput = false;
}

void AVaQuoleUIPlayerController::InitInputSystem()
{
	Super::InitInputSystem();

	BIND_ACTION(InputComponent, "MouseDown", IE_Pressed, &AVaQuoleUIPlayerController::MouseDown);
	BIND_ACTION(InputComponent, "MouseUp", IE_Released, &AVaQuoleUIPlayerController::MouseUp);
}

void AVaQuoleUIPlayerController::PlayerTick(float DeltaTime)
{
	Super::PlayerTick(DeltaTime);

	MouseEvent(EMouseEvent::MouseMove, VaQuole::EMouseButton::NoButton);
}

void AVaQuoleUIPlayerController::InputKeyQ(FViewport* Viewport, FKey Key, EInputEvent EventType, float AmountDepressed, bool bGamepad)
{
	FVector ActorImpact;
	UVaQuoleUIComponent* View;
	UStaticMeshComponent* Mesh;

	// Check we're targeting UI on scene
	if (GetTargetUIComponent(ActorImpact, &View, &Mesh))
	{
		View->InputKeyQ(Viewport, Key, EventType, AmountDepressed, bGamepad);
	}

	// Check we have HUD
	AVaQuoleHUD* MyHUD = GetVaQuoleHUD();
	if (MyHUD && MyHUD->VaQuoleUI.IsValid())
	{
		MyHUD->VaQuoleUI->InputKeyQ(Viewport, Key, EventType, AmountDepressed, bGamepad);
	}
}

void AVaQuoleUIPlayerController::MouseEvent(EMouseEvent::Type MouseEvent, VaQuole::EMouseButton::Type Button)
{
	FVector ActorImpact;
	UVaQuoleUIComponent* View;
	UStaticMeshComponent* Mesh;

	if (GetTargetUIComponent(ActorImpact, &View, &Mesh))
	{
		FVector Min, Max;

		Mesh->GetLocalBounds(Min, Max);

		if (bDebugMouseInput)
		{
			UE_LOG(LogVaQuole, Warning, TEXT("Min %s"), *Min.ToString());
			UE_LOG(LogVaQuole, Warning, TEXT("Max %s"), *Max.ToString());
		}

		// @TODO Add rotation modificator
		int32 X = View->GetWidth() * (ActorImpact.X - Min.X) / (Max.X - Min.X);
		int32 Y = View->GetHeight() * (Max.Z - ActorImpact.Z) / (Max.Z - Min.Z);

		switch (MouseEvent)
		{
		case EMouseEvent::MouseMove:
			View->MouseMove(X, Y);
			break;

		case EMouseEvent::MousePressed:
			View->MouseClick(X, Y, Button, true);
			break;

		case EMouseEvent::MouseReleased:
			View->MouseClick(X, Y, Button, false);
			break;

		default:
			break;
		}
	}

	AVaQuoleHUD* MyHUD = GetVaQuoleHUD();
	if (MyHUD && MyHUD->VaQuoleUI.IsValid())
	{
		FVector2D MousePosition = FVector2D::ZeroVector;
		if (GetMouseScreenPosition(MousePosition))
		{
			switch (MouseEvent)
			{
			case EMouseEvent::MouseMove:
				MyHUD->VaQuoleUI->MouseMove(MousePosition.X, MousePosition.Y);
				break;

			case EMouseEvent::MousePressed:
				MyHUD->VaQuoleUI->MouseClick(MousePosition.X, MousePosition.Y, Button, true);
				break;

			case EMouseEvent::MouseReleased:
				MyHUD->VaQuoleUI->MouseClick(MousePosition.X, MousePosition.Y, Button, false);
				break;

			default:
				break;
			}
		}
	}
}


//////////////////////////////////////////////////////////////////////////
// Mouse input example

void AVaQuoleUIPlayerController::MouseDown()
{
	MouseEvent(EMouseEvent::MousePressed, VaQuole::EMouseButton::LeftButton);
}

void AVaQuoleUIPlayerController::MouseUp()
{
	MouseEvent(EMouseEvent::MouseReleased, VaQuole::EMouseButton::LeftButton);
}

void AVaQuoleUIPlayerController::EvalJS(FString ScriptSource)
{
	AVaQuoleHUD* MyHUD = GetVaQuoleHUD();
	if (MyHUD && MyHUD->VaQuoleUI.IsValid() && MyHUD->VaQuoleUI->GetUIWidget().IsValid())
	{
		MyHUD->VaQuoleUI->GetUIWidget()->EvaluateJavaScript(*ScriptSource);
	}
}


//////////////////////////////////////////////////////////////////////////
{'fraction_non_alphanumeric': 0.1725622885266072, 'fraction_numerical': 0.0027683789603199014, 'mean_word_length': 4.396680497925312, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '6438028', 'n_tokens_mistral': 2446, 'n_tokens_neox': 2283, 'n_words': 386}