This commit is contained in:
wonkyhonky2024
2025-05-15 19:28:04 +01:00
parent 23691e77c2
commit ff30856c60
16 changed files with 109 additions and 33 deletions

Binary file not shown.

BIN
Content/LinacLab/MyMyUserWidget.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/LinacLab/vt100_Blueprint.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -1,4 +1,4 @@
#pragma once
#include <HsFFI.h> #include <HsFFI.h>
typedef enum ExtCallType { typedef enum ExtCallType {

View File

@ -43,11 +43,19 @@ void UTheracAdapterComponent::WrapSimulatorCall(
EBeamType beam_type, EBeamType beam_type,
ECollimatorPosition collimator_position, ECollimatorPosition collimator_position,
int32 beam_energy int32 beam_energy
) {} ) {
UpdateSimulator(
ExtCallType(ext_call_type),
wrappedComms,
BeamType(beam_type),
CollimatorPosition(collimator_position),
beam_energy
);
}
// Called when the game starts // Called when the game starts
void UTheracAdapterComponent::BeginPlay() { void UTheracAdapterComponent::BeginPlay() {
/*
FString BaseDir = FString BaseDir =
IPluginManager::Get().FindPlugin("hstherac25")->GetBaseDir(); IPluginManager::Get().FindPlugin("hstherac25")->GetBaseDir();
FString LibraryPath = FString LibraryPath =
@ -56,7 +64,7 @@ void UTheracAdapterComponent::BeginPlay() {
simulatorLibraryHandle = !LibraryPath.IsEmpty() simulatorLibraryHandle = !LibraryPath.IsEmpty()
? FPlatformProcess::GetDllHandle(*LibraryPath) ? FPlatformProcess::GetDllHandle(*LibraryPath)
: nullptr; : nullptr;
*/
Super::BeginPlay(); Super::BeginPlay();
wrappedComms = start_machine(); wrappedComms = start_machine();
std::map<FText *, StateInfoRequest> hng = { std::map<FText *, StateInfoRequest> hng = {
@ -70,6 +78,7 @@ void UTheracAdapterComponent::BeginPlay() {
for (auto & [hnng, hnnng] : hng) { for (auto & [hnng, hnnng] : hng) {
compMap.Add(hnng, hnnng); compMap.Add(hnng, hnnng);
} }
ExtCallTypeMap.Add("T", EExtCallType::ExtCallSendMEOS);
ExtCallTypeMap.Add("R", EExtCallType::ExtCallReset); ExtCallTypeMap.Add("R", EExtCallType::ExtCallReset);
ExtCallTypeMap.Add("P", EExtCallType::ExtCallProceed); ExtCallTypeMap.Add("P", EExtCallType::ExtCallProceed);
@ -84,13 +93,13 @@ void UTheracAdapterComponent::BeginPlay() {
// ... // ...
} }
/*
void UTheracAdapterComponent::shutdownSimulator() { void UTheracAdapterComponent::shutdownSimulator() {
kill_machine(); kill_machine();
FPlatformProcess::FreeDllHandle(simulatorLibraryHandle); FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
simulatorLibraryHandle = nullptr; simulatorLibraryHandle = nullptr;
} }
*/
// Called every frame // Called every frame
void UTheracAdapterComponent::TickComponent( void UTheracAdapterComponent::TickComponent(
float DeltaTime, float DeltaTime,

View File

@ -13,16 +13,17 @@
void Fhstherac25Module::StartupModule() { void Fhstherac25Module::StartupModule() {
// This code will execute after your module is loaded into memory; the exact // This code will execute after your module is loaded into memory; the exact
// timing is specified in the .uplugin file per-module // timing is specified in the .uplugin file per-module
/*
// Get the base directory of this plugin // Get the base directory of this plugin
FString BaseDir = FString BaseDir =
IPluginManager::Get().FindPlugin("hstherac25")->GetBaseDir(); IPluginManager::Get().FindPlugin("hstherac25")->GetBaseDir();
// Add on the relative location of the third party dll and load it // Add on the relative location of the third party dll and load it
/ FString LibraryPath; FString LibraryPath;
#if PLATFORM_WINDOWS #if PLATFORM_WINDOWS
LibraryPath = FPaths::Combine(*BaseDir, TEXT("Source/hstherac-hs/HSdll.dll")); LibraryPath =
// FPaths::Combine(*BaseDir, TEXT("Binaries/Win64/hstherac25.dll"));
FPaths::Combine(*BaseDir, TEXT("Binaries/Win64/HSdll.dll"));
#elif PLATFORM_MAC #elif PLATFORM_MAC
LibraryPath = FPaths::Combine( LibraryPath = FPaths::Combine(
*BaseDir, *BaseDir,
@ -55,7 +56,6 @@ void Fhstherac25Module::StartupModule() {
) )
); );
} }
*/
} }
void Fhstherac25Module::ShutdownModule() { void Fhstherac25Module::ShutdownModule() {
@ -64,8 +64,9 @@ void Fhstherac25Module::ShutdownModule() {
// unloading the module. // unloading the module.
// Free the dll handle // Free the dll handle
// FPlatformProcess::FreeDllHandle(simulatorLibraryHandle); kill_machine();
// simulatorLibraryHandle = nullptr; FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
simulatorLibraryHandle = nullptr;
} }
#undef LOCTEXT_NAMESPACE #undef LOCTEXT_NAMESPACE

View File

@ -45,8 +45,6 @@ class HSTHERAC25_API UTheracAdapterComponent : public UActorComponent {
TMap<FText *, StateInfoRequest> compMap; TMap<FText *, StateInfoRequest> compMap;
void * simulatorLibraryHandle;
void UpdateSimulator( void UpdateSimulator(
ExtCallType ect, ExtCallType ect,
HsStablePtr wrapped_comms = nullptr, HsStablePtr wrapped_comms = nullptr,
@ -100,7 +98,8 @@ public:
protected: protected:
// Called when the game starts // Called when the game starts
virtual void BeginPlay() override; virtual void BeginPlay() override;
void shutdownSimulator();
// void shutdownSimulator();
public: public:
// Called every frame // Called every frame

View File

@ -12,5 +12,5 @@ public:
private: private:
/** Handle to the test dll we will load */ /** Handle to the test dll we will load */
// void * simulatorLibraryHandle; void * simulatorLibraryHandle;
}; };

View File

@ -63,7 +63,9 @@ public class hstherac25 : ModuleRules
// ... add any modules that your module loads dynamically here ... // ... add any modules that your module loads dynamically here ...
} }
); );
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "../hstherac-hs", "hstherac25.dll.a")); // PublicAdditionalLibraries.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "hstherac25.dll.a"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "../hstherac-hs/hstherac25.dll")); // RuntimeDependencies.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "hstherac25.dll"));
PublicAdditionalLibraries.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "HSdll.dll.a"));
RuntimeDependencies.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "HSdll.dll"));
} }
} }

View File

@ -9,6 +9,6 @@ public class MyProjectTarget : TargetRules
Type = TargetType.Game; Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V5; DefaultBuildSettings = BuildSettingsVersion.V5;
ExtraModuleNames.AddRange(new string[] { "MyProject", "hstherac25" }); ExtraModuleNames.AddRange(new string[] { "MyProject", });
} }
} }

View File

@ -13,7 +13,7 @@ public class MyProject : ModuleRules
PrivateDependencyModuleNames.AddRange(new string[] { }); PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI // Uncomment if you are using Slate UI
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore", "hstherac25" }); PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features // Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem"); // PrivateDependencyModuleNames.Add("OnlineSubsystem");

View File

@ -1,37 +1,53 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "ModeInputTextBox.h" #include "ModeInputTextBox.h"
#include <Logging/StructuredLog.h>
void UModeInputTextBox::HandleOnTextChanged(FText const & inText) { void UModeInputTextBox::HandleOnTextChanged(FText const & inText) {
Text = Text.GetEmpty();
auto & s = inText.ToString(); auto & s = inText.ToString();
auto lastChar = s.LeftChop(1); // UE_LOGFMT(LogTemp, Warning, "kill me {inText}", s);
lastChar.ToUpperInline();
auto lastChar = s.ToUpper().Right(1);
// UE_LOGFMT(LogTemp, Warning, "fucking {lastChar}", lastChar);
SetText(FText::FromString(lastChar));
if (!lastChar.IsEmpty()) { if (!lastChar.IsEmpty()) {
switch (myTarget) { switch (myTarget) {
case THSModeTarget::Energy: case THSModeTarget::Energy:
switch (lastChar[0]) { switch (lastChar[lastChar.Len() - 1]) {
case 'E': case 'E':
break; break;
case 'X': case 'X':
break; break;
default: default:
lastChar[lastChar.Len() - 1] = '\0';
break; break;
} }
break; break;
case THSModeTarget::OpMode: case THSModeTarget::OpMode:
switch (lastChar[0]) { switch (lastChar[lastChar.Len() - 1]) {
case 'T': case 'T':
break; break;
case 'R': case 'R':
break; break;
case 'P': case 'P':
break; break;
default:
lastChar = "";
} }
break; break;
default: default:
break; break;
} }
} }
// UE_LOGFMT(LogTemp, Warning, "wat {lastChar}", lastChar);
SetText(FText::FromString(lastChar)); SetText(FText::FromString(lastChar));
// SetText(FText::FromString(FString::Printf(TEXT("%c"), lastChar)));
} }

View File

@ -3,6 +3,25 @@
#include "MyUserWidget.h" #include "MyUserWidget.h"
#include <MyPlayerState.h> #include <MyPlayerState.h>
bool UMyUserWidget::AllVerified() {
UTextBlock * myVerifiers[9] = {
URM_Verifier,
MU_Verifier,
Time_Verifier,
GR_Verifier,
CR_Verifier,
ColX_Verifier,
ColY_Verifier,
WN_Verifier,
AN_Verifier
};
for (auto & v : myVerifiers) {
if (v->GetText().IsEmpty())
return false;
}
return true;
}
void UMyUserWidget::NativeOnInitialized() { void UMyUserWidget::NativeOnInitialized() {
auto ps = StaticCast<AMyPlayerState *>(GetOwningPlayerState()); auto ps = StaticCast<AMyPlayerState *>(GetOwningPlayerState());
if (ps == nullptr) if (ps == nullptr)

View File

@ -45,5 +45,35 @@ class MYPROJECT_API UMyUserWidget : public UUserWidget {
UPROPERTY(meta = (BindWidget)) UPROPERTY(meta = (BindWidget))
UTextBlock * AN_TextBlock; UTextBlock * AN_TextBlock;
UPROPERTY(meta = (BindWidget))
UTextBlock * URM_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * MU_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * Time_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * GR_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * CR_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * ColX_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * ColY_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * WN_Verifier;
UPROPERTY(meta = (BindWidget))
UTextBlock * AN_Verifier;
UFUNCTION(BlueprintCallable, BluePrintPure)
bool AllVerified();
void NativeOnInitialized() override; void NativeOnInitialized() override;
}; };

View File

@ -9,6 +9,6 @@ public class MyProjectEditorTarget : TargetRules
Type = TargetType.Editor; Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V5; DefaultBuildSettings = BuildSettingsVersion.V5;
ExtraModuleNames.AddRange(new string[] { "MyProject", "hstherac25" }); ExtraModuleNames.AddRange(new string[] { "MyProject", });
} }
} }