Skip to content
Snippets Groups Projects
Commit e7c8cb01 authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Removed old stuff

parent 69d59ec8
Branches
No related tags found
No related merge requests found
Showing with 0 additions and 522 deletions
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "CAVELaunchButton",
"Description": "",
"Category": "Other",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"EnabledByDefault" : true,
"Modules": [
{
"Name": "CAVELaunchButton",
"Type": "Editor",
"LoadingPhase": "Default"
}
]
}
\ No newline at end of file
Resources/CAVEIcon_40x.png

5.47 KiB

Resources/ROLVIcon_40x.png

710 B

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class CAVELaunchButton : ModuleRules
{
public CAVELaunchButton(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"Projects",
"InputCore",
"UnrealEd",
"LevelEditor",
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"Sockets",
"Networking"
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CAVELaunchButton.h"
#include <string>
#include "CAVELaunchButtonStyle.h"
#include "CAVELaunchButtonSettings.h"
#include "CAVELaunchButtonCommands.h"
#include "Misc/MessageDialog.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "IPluginManager.h"
#include "Misc/EngineVersion.h"
#include "Networking.h"
#include "LevelEditor.h"
#define LOCTEXT_NAMESPACE "FCAVELaunchButtonModule"
void FCAVELaunchButtonModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
FCAVELaunchButtonStyle::Initialize();
FCAVELaunchButtonStyle::ReloadTextures();
FCAVELaunchButtonCommands::Register();
PluginCommands = MakeShareable(new FUICommandList);
PluginCommands->MapAction(
FCAVELaunchButtonCommands::Get().PluginAction,
FExecuteAction::CreateRaw(this, &FCAVELaunchButtonModule::PluginButtonClicked),
FCanExecuteAction());
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
{
TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);
ToolbarExtender->AddToolBarExtension("Game", EExtensionHook::First, PluginCommands, FToolBarExtensionDelegate::CreateRaw(this, &FCAVELaunchButtonModule::AddToolbarExtension));
LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender);
}
}
void FCAVELaunchButtonModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
FCAVELaunchButtonStyle::Shutdown();
FCAVELaunchButtonCommands::Unregister();
}
void FCAVELaunchButtonModule::PluginButtonClicked()
{
// minimize the root window to provide max performance for the preview.
TSharedPtr<SWindow> RootWindow = FGlobalTabmanager::Get()->GetRootWindow();
if (RootWindow.IsValid()) RootWindow->Minimize();
#if PLATFORM_WINDOWS
const UCAVELaunchButtonSettings* Settings = GetDefault<UCAVELaunchButtonSettings>();
if (Settings->StartROLVInsteadOfCAVE) {
FString EditorExecutable = "UE4Editor.exe";
FString Parameters = "\"" + FPaths::GetProjectFilePath() + "\" -game -dc_cluster -nosplash -fixedseed -dx11 -dc_dev_side_by_side dc_cfg=\"" + Settings->RolvConfig.FilePath + "\" -notexturestreaming -fullscreen dc_node=node_main -log ABSLOG=" + FPaths::ProjectDir() + "\\ROLV_Launch.log";
FProcHandle VRPN;
ProjectorDisplayType modeFromBefore;
if (Settings->StartVRPN) VRPN = FPlatformProcess::CreateProc(*Settings->VRPNPath.FilePath, *FString("-f \"" + Settings->VRPNConfigPath.FilePath + "\" -millisleep 0"), false, false, false, NULL, 0, NULL, NULL);
if (Settings->StartDTrack) SendToDTrack(Settings->DTrackIP, Settings->DTrackPort, "dtrack2 tracking start\0");
if (Settings->SwitchBeamer) modeFromBefore = SwitchBeamerToState(Settings->BeamerIP, Settings->BeamerPort, Settings->BeamerType);
FProcHandle instance = FPlatformProcess::CreateProc(*EditorExecutable, *(Parameters + " " + Settings->AdditionalParameters), true, false, false, NULL, 0, NULL, NULL);
FPlatformProcess::WaitForProc(instance);
if (Settings->StartVRPN) FPlatformProcess::TerminateProc(VRPN); FPlatformProcess::CloseProc(VRPN);
if (Settings->StartDTrack) SendToDTrack(Settings->DTrackIP, Settings->DTrackPort, "dtrack2 tracking stop\0");
if (Settings->SwitchBeamer && modeFromBefore != DisplayType_Error) SwitchBeamerToState(Settings->BeamerIP, Settings->BeamerPort, modeFromBefore);
} else {
FString Config = IPluginManager::Get().FindPlugin("CAVELaunchButton")->GetBaseDir() + "/LaunchConfig/minicave.cfg";
FString EditorExecutable = "UE4Editor.exe";
FString Parameters = "\"" + FPaths::GetProjectFilePath() + "\" -game -windowed -fixedseed -notexturestreaming -opengl4 dc_cfg=\"" + Config + "\" -dc_cluster -dc_dev_mono";
const int num_nodes = 5;
FString Windows_Node_Specific_Commands[num_nodes] = {
"dc_node=node_floor WinX=720 WinY=300 ResX=480 ResY=480 -log ABSLOG=" + FPaths::ProjectDir() + "\\MiniCaveMulti.log " + Settings->AdditionalParameters + " " + Settings->AdditionalParametersMaster,
"dc_node=node_front WinX=720 WinY=0 ResX=480 ResY=300 " + Settings->AdditionalParameters,
"dc_node=node_left WinX=420 WinY=300 ResX=300 ResY=480 " + Settings->AdditionalParameters,
"dc_node=node_right WinX=1200 WinY=300 ResX=300 ResY=480 " + Settings->AdditionalParameters,
"dc_node=node_back WinX=720 WinY=780 ResX=480 ResY=300 " + Settings->AdditionalParameters
};
FProcHandle processes[num_nodes];
for(int i = 0; i < num_nodes; i++){
processes[i] = FPlatformProcess::CreateProc(*EditorExecutable, *(Parameters + " " + Windows_Node_Specific_Commands[i]), true, false, false, NULL, 0, NULL, NULL);
}
FPlatformProcess::WaitForProc(processes[num_nodes - 1]);
}
#elif PLATFORM_LINUX
FProcHandle process = FPlatformProcess::CreateProc(*FString("/home/av006de/demos_UNREAL/.misc/scripts/cave/launch_aixcave_editor.sh"), *("\"" + (FPaths::ConvertRelativePathToFull(FPaths::EngineDir()) + "Binaries/Linux/UE4Editor\" ") + FPaths::ConvertRelativePathToFull(FPaths::GetProjectFilePath()) + " " + FString::FromInt(FEngineVersion::Current().GetMajor()) + FString::FromInt(FEngineVersion::Current().GetMinor())), true, false, false, NULL, 0, NULL, NULL);
FPlatformProcess::WaitForProc(process);
#endif
if (RootWindow.IsValid()) RootWindow->Maximize();
}
FSocket* openSocket(FString address, int port, FString socketName) {
FIPv4Address parsedAddress;
if (!FIPv4Address::Parse(address, parsedAddress)) {
UE_LOG(LogTemp, Error, TEXT("Could not parse Address %s"), *address);
return NULL;
}
FIPv4Endpoint endpoint(parsedAddress, port);
FSocket* socket = FTcpSocketBuilder(*socketName);
if (!socket->Connect(endpoint.ToInternetAddr().Get()))
{
UE_LOG(LogTemp, Error, TEXT("Error connecting to server %s:%d via %s"), *address, port, *socketName);
socket->Close();
return NULL;
}
return socket;
}
int32 sendSocket(FSocket* socket, FString message) {
socket->Wait(ESocketWaitConditions::WaitForWrite, FTimespan::FromSeconds(5));
std::string buffer = std::string(TCHAR_TO_UTF8(*message));
int32 sent = 0;
if (!socket->Send((const uint8 *)buffer.c_str(), buffer.length(), sent))
{
UE_LOG(LogTemp, Error, TEXT("Error sending via %s. Sent %d bytes"), *socket->GetDescription() , sent);
socket->Close();
}
return sent;
}
template<int32 bufferSize> FString receiveSocket(FSocket* socket) {
socket->Wait(ESocketWaitConditions::WaitForRead, FTimespan::FromSeconds(5));
char receivebuffer[bufferSize];
int bytesReceived = 0;
if (!socket->Recv((uint8*)&receivebuffer, bufferSize, bytesReceived)) {
UE_LOG(LogTemp, Error, TEXT("No valid response from %s. Response: '%s'"), *socket->GetDescription(), *FString(std::string(receivebuffer, bytesReceived).c_str()));
socket->Close();
}
if (bytesReceived <= 0) return FString("");
return FString(std::string(receivebuffer, bytesReceived).c_str());
}
void FCAVELaunchButtonModule::SendToDTrack(FString address, int port, FString message) {
FSocket* socket = openSocket(address, port, "DTrackSocket");
if (!socket) return;
if (sendSocket(socket, message) <= 0) return;
FString response = receiveSocket<100>(socket);
if (response.Compare("dtrack2 ok") != 0) {
UE_LOG(LogTemp, Error, TEXT("DTrack Command Failed. Response: '%s'"), *response);
}
socket->Shutdown(ESocketShutdownMode::ReadWrite);
socket->Close();
}
//Returns old state
ProjectorDisplayType FCAVELaunchButtonModule::SwitchBeamerToState(FString address, int port, ProjectorDisplayType state) {
ProjectorDisplayType modeBefore = ProjectorDisplayType::DisplayType_Error;
FSocket* socket = openSocket(address, port, "BeamerSocket");
if (!socket) return modeBefore;
//Get mode from before
if (sendSocket(socket, ":TDSM ?\r") <= 0) return modeBefore;
FString response = receiveSocket<100>(socket); //%001 TDSM 000000
if (!response.IsEmpty()) {
int32 position = 0;
response.FindLastChar(' ', position);
modeBefore = (ProjectorDisplayType)FCString::Atoi(*response.RightChop(position));
}
if (response.IsEmpty() || sendSocket(socket, ":TDSM " + FString::FromInt(state) + "\r") <= 0) {
socket->Shutdown(ESocketShutdownMode::ReadWrite);
socket->Close();
return modeBefore;
}
response = receiveSocket<100>(socket);
if (response.EndsWith(")")) {
UE_LOG(LogTemp, Error, TEXT("Beamer Type Change Failed. Response: '%s'"), *response);
}
socket->Shutdown(ESocketShutdownMode::ReadWrite);
socket->Close();
return modeBefore;
}
void FCAVELaunchButtonModule::AddToolbarExtension(FToolBarBuilder& Builder)
{
Builder.AddToolBarButton(FCAVELaunchButtonCommands::Get().PluginAction);
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FCAVELaunchButtonModule, CAVELaunchButton)
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CAVELaunchButtonCommands.h"
#include "CAVELaunchButtonSettings.h"
#define LOCTEXT_NAMESPACE "FCAVELaunchButtonModule"
void FCAVELaunchButtonCommands::RegisterCommands()
{
if(GetDefault<UCAVELaunchButtonSettings>()->StartROLVInsteadOfCAVE)
{
UI_COMMAND(PluginAction, "PlayOnROLV", "Launch current project on ROLV", EUserInterfaceActionType::Button, FInputGesture());
}else
{
UI_COMMAND(PluginAction, "PlayInCAVE", "Launch current project in CAVE", EUserInterfaceActionType::Button, FInputGesture());
}
}
#undef LOCTEXT_NAMESPACE
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CAVELaunchButtonStyle.h"
#include "CAVELaunchButton.h"
#include "Framework/Application/SlateApplication.h"
#include "Styling/SlateStyleRegistry.h"
#include "Slate/SlateGameResources.h"
#include "Interfaces/IPluginManager.h"
#include "CAVELaunchButtonSettings.h"
TSharedPtr< FSlateStyleSet > FCAVELaunchButtonStyle::StyleInstance = NULL;
void FCAVELaunchButtonStyle::Initialize()
{
if (!StyleInstance.IsValid())
{
StyleInstance = Create();
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
}
}
void FCAVELaunchButtonStyle::Shutdown()
{
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
ensure(StyleInstance.IsUnique());
StyleInstance.Reset();
}
FName FCAVELaunchButtonStyle::GetStyleSetName()
{
static FName StyleSetName(TEXT("CAVELaunchButtonStyle"));
return StyleSetName;
}
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ )
#define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ )
const FVector2D Icon16x16(16.0f, 16.0f);
const FVector2D Icon20x20(20.0f, 20.0f);
const FVector2D Icon40x40(40.0f, 40.0f);
TSharedRef< FSlateStyleSet > FCAVELaunchButtonStyle::Create()
{
TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("CAVELaunchButtonStyle"));
Style->SetContentRoot(IPluginManager::Get().FindPlugin("CAVELaunchButton")->GetBaseDir() / TEXT("Resources"));
if (GetDefault<UCAVELaunchButtonSettings>()->StartROLVInsteadOfCAVE)
{
Style->Set("CAVELaunchButton.PluginAction", new IMAGE_BRUSH(TEXT("ROLVIcon_40x"), Icon40x40));
}else
{
Style->Set("CAVELaunchButton.PluginAction", new IMAGE_BRUSH(TEXT("CAVEIcon_40x"), Icon40x40));
}
return Style;
}
#undef IMAGE_BRUSH
#undef BOX_BRUSH
#undef BORDER_BRUSH
#undef TTF_FONT
#undef OTF_FONT
void FCAVELaunchButtonStyle::ReloadTextures()
{
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
}
}
const ISlateStyle& FCAVELaunchButtonStyle::Get()
{
return *StyleInstance;
}
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "CAVELaunchButtonSettings.h"
class FToolBarBuilder;
class FMenuBuilder;
class FCAVELaunchButtonModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/** This function will be bound to Command. */
void PluginButtonClicked();
void SendToDTrack(FString address, int port, FString message);
ProjectorDisplayType SwitchBeamerToState(FString address, int port, ProjectorDisplayType state);
private:
void AddToolbarExtension(FToolBarBuilder& Builder);
private:
TSharedPtr<class FUICommandList> PluginCommands;
};
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Framework/Commands/Commands.h"
#include "CAVELaunchButtonStyle.h"
class FCAVELaunchButtonCommands : public TCommands<FCAVELaunchButtonCommands>
{
public:
FCAVELaunchButtonCommands()
: TCommands<FCAVELaunchButtonCommands>(TEXT("CAVELaunchButton"), NSLOCTEXT("Contexts", "CAVELaunchButton", "CAVELaunchButton Plugin"), NAME_None, FCAVELaunchButtonStyle::GetStyleSetName())
{
}
// TCommands<> interface
virtual void RegisterCommands() override;
public:
TSharedPtr< FUICommandInfo > PluginAction;
};
#pragma once
#include "CoreMinimal.h"
#include "Engine/DeveloperSettings.h"
#include "CAVELaunchButtonSettings.generated.h"
UENUM(BlueprintType)
enum ProjectorDisplayType
{
DisplayType_Off = 0,
DisplayType_Frame_Sequential = 1,
DisplayType_Side_By_Side = 2,
DisplayType_DualHead = 3,
DisplayType_Error = 4 UMETA(Hidden)
};
UCLASS(config=Engine, defaultconfig, meta=(DisplayName="nDisplay Launch Button"))
class UCAVELaunchButtonSettings : public UDeveloperSettings
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, config, Category = LaunchParametersWindows)
FString AdditionalParameters = "";
UPROPERTY(EditAnywhere, config, Category = LaunchParametersWindows)
FString AdditionalParametersMaster = "";
UPROPERTY(EditAnywhere, config, Category = ROLV, meta = (ConfigRestartRequired = true))
bool StartROLVInsteadOfCAVE = false;
UPROPERTY(EditAnywhere, config, Category = ROLV)
FFilePath RolvConfig;
UPROPERTY(EditAnywhere, config, Category = "ROLV|Beamer")
bool SwitchBeamer = true;
UPROPERTY(EditAnywhere, config, Category = "ROLV|Beamer", meta = (EditCondition = "SwitchBeamer"))
TEnumAsByte<ProjectorDisplayType> BeamerType;
UPROPERTY(EditAnywhere, config, Category = "ROLV|Beamer", meta = (EditCondition = "SwitchBeamer"))
FString BeamerIP;
UPROPERTY(EditAnywhere, config, Category = "ROLV|Beamer", meta = (EditCondition = "SwitchBeamer"))
int BeamerPort = 1025;
UPROPERTY(EditAnywhere, config, Category = "ROLV|VRPN")
bool StartVRPN = true;
UPROPERTY(EditAnywhere, config, Category = "ROLV|VRPN", meta = (EditCondition = "StartVRPN"))
FFilePath VRPNPath;
UPROPERTY(EditAnywhere, config, Category = "ROLV|VRPN", meta = (EditCondition = "StartVRPN"))
FFilePath VRPNConfigPath;
UPROPERTY(EditAnywhere, config, Category = "ROLV|DTRACK")
bool StartDTrack = true;
UPROPERTY(EditAnywhere, config, Category = "ROLV|DTRACK", meta= (EditCondition = "StartDTrack"))
FString DTrackIP;
UPROPERTY(EditAnywhere, config, Category = "ROLV|DTRACK", meta = (EditCondition = "StartDTrack"))
int DTrackPort = 50105;
};
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Styling/SlateStyle.h"
class FCAVELaunchButtonStyle
{
public:
static void Initialize();
static void Shutdown();
/** reloads textures used by slate renderer */
static void ReloadTextures();
/** @return The Slate style set for the Shooter game */
static const ISlateStyle& Get();
static FName GetStyleSetName();
private:
static TSharedRef< class FSlateStyleSet > Create();
private:
static TSharedPtr< class FSlateStyleSet > StyleInstance;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment