Skip to content

Instantly share code, notes, and snippets.

View PapeCoding's full-sized avatar

Sebi PapeCoding

View GitHub Profile
@PapeCoding
PapeCoding / DasherMouseInput.cpp
Created January 11, 2024 11:56
Simple Exponential Moving Average Filter for Dasher Mouse Input
// replace the content of the function with the one below:
[...]
bool CDasherMouseInput::GetScreenCoords(screenint &iX, screenint &iY, CDasherView *pView)
{
POINT mousepos;
GetCursorPos(&mousepos);
ScreenToClient(m_hwnd, &mousepos);
@PapeCoding
PapeCoding / FaceIT-HyperV-Toggle.ps1
Last active March 9, 2021 21:32
Toggle HyperV for the FACEIT Anti-Cheat
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{ Write-Host "No Adminrights. restart as Administrator"
$arguments = "& ‚" + $myinvocation.mycommand.definition + "‚"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$oldValue = (bcdedit | Select-String -Pattern "hypervisorlaunchtype").toString().split() | select -Last 1
If ( $oldValue -eq "Off")
@PapeCoding
PapeCoding / UnrealAssetLoading.cpp
Last active March 10, 2020 10:30
This shows how an Asset can be loaded from C++. Here a Plane and a corresponding Material is loaded
template <typename T>
bool LoadAsset(const FString& Path, T* & Result)
{
ConstructorHelpers::FObjectFinder<T> Loader(*Path);
Result = Loader.Object;
if (!Loader.Succeeded()) UE_LOG(LogTemp, Error, TEXT("Could not find %s. Have you renamed it?"), *Path);
return Loader.Succeeded();
}
AMyClass::AMyClass()
@PapeCoding
PapeCoding / UnrealCreateC++UMGBinding.hpp
Last active March 9, 2020 16:08
This shows how an UMG widget can be bound/controlled from C++
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "TextBlock.h"
#include "Border.h"
#include "MySpecificUserWidget.generated.h"
/**
*
@PapeCoding
PapeCoding / UnrealCreateUMGWidgetFromC++.cpp
Created March 9, 2020 15:28
This allows the spawning of a widget from C++, which is then attached to the viewport
// Declare this in Header
TSubclassOf<class UUserWidget> Overlay_Class;
UUserWidget* Overlay;
// Do this in Constructor
ConstructorHelpers::FClassFinder<UUserWidget> WidgetClassFinder(TEXT("WidgetBlueprint'/MyPlugin/MyWidgetName'"));
if (WidgetClassFinder.Succeeded())
{
Overlay_Class = WidgetClassFinder.Class;
}
@PapeCoding
PapeCoding / UnrealRedirectClass.ini
Created March 9, 2020 15:22
This allows to rename a C++ class without breaking every blueprint that inherits from it
# Open Configs/DefaultEngine.ini of your project and under [/Script/Engine.Engine] section add the below line:
+ActiveClassRedirects=(OldClassName="/Script/MyOldClassName",NewClassName="/Script/MyNewClassName")
# This can look like this in a plugin:
+ActiveClassRedirects=(OldClassName="/Script/MyPlugin.MyClass",NewClassName="/Script/MyPlugin.MyClass2")
# If you are not sure how the reference looks like, you can right click your C++ class in the editor and copy the reference
@PapeCoding
PapeCoding / UnrealActionMappingAndBind.cpp
Last active March 9, 2020 15:20
This allows binding "keys" to functions indirectly, by introducing a unique action, which calls your method with your parameter(s).
// Declare inside your Unreal Class
DECLARE_DELEGATE_OneParam(FMyActionDelegate, float);
//Do in function like BeginPlay or the StartupModule function of your Plugin
UInputSettings::GetInputSettings()->AddActionMapping(FInputActionKeyMapping(TEXT("MyTestAction"),EKeys::T));
UInputSettings::GetInputSettings()->SaveKeyMappings();
InputComponent->BindAction<FMyActionDelegate>(TEXT("MyTestAction"),EInputEvent::IE_Pressed,this,&MyClass::MyFunctionHandler,-0.1337f);
@PapeCoding
PapeCoding / UnrealHLSLAccessSceneTextureByName.ush
Last active March 9, 2020 15:22
Unreal PostProcess Access Textures by Name in HLSL
// All members of the GBuffer can be found here:
// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/DeferredShadingCommon.ush#L301
#if SCENE_TEXTURES_DISABLED
return 0;
#endif
return GetScreenSpaceData(GetSceneTextureUV(Parameters), false).GBuffer.CustomStencil.x == 1;
@PapeCoding
PapeCoding / GetTweetsText.js
Last active January 30, 2019 21:47
Get all displayed tweets from a timeline as plaintext in single lines! This is very usefull to get data from twitter without having an api key. This especially works fine on the "advanced search"-results!
a = ""; Array.from(document.getElementsByClassName("tweet-text")).forEach(function(t) {if(t.getAttribute("lang") == "en") a += t.innerText.replace(/\n|\s\s+/g, " ").trim() + "\n"}); var input = document.createElement("textarea"); document.querySelectorAll('.AppContent-main, .AppContent')[0].prepend(input); input.value = a;