Hotkeys working now

This commit is contained in:
2025-06-02 19:21:17 -04:00
parent 7e8b96cb84
commit 8940dd9e70
14 changed files with 82 additions and 20 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -134,6 +134,15 @@ FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataName(FName Value, co
return Result;
}
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataKey(FKey Value, const FString &Name)
{
FFormatArgumentData Result;
Result.ArgumentValueType = EFormatArgumentType::Text;
Result.ArgumentName = Name;
Result.ArgumentValue = UKismetTextLibrary::Conv_NameToText(Value.GetFName());
return Result;
}
FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataGender(ETextGender Value, const FString &Name)
{
FFormatArgumentData Result;

View File

@@ -125,6 +125,9 @@ public:
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
static FFormatArgumentData FormatArgumentDataName(FName Value, const FString &Name);
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
static FFormatArgumentData FormatArgumentDataKey(FKey Value, const FString &Name);
UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility")
static FFormatArgumentData FormatArgumentDataGender(ETextGender Value, const FString &Name);

View File

@@ -37,6 +37,12 @@ enum class ElxSuccessOrError : uint8 {
Error,
};
UENUM(BlueprintType)
enum class ElxValidOrNotValid : uint8 {
Valid,
NotValid,
};
UENUM(BlueprintType)
enum class ElxFoundOrNotFound : uint8 {
Found,

View File

@@ -227,3 +227,14 @@ ElxUsedOrNotUsed UlxUtilityLibrary::IsKeyUsedByMappingContext(const FKey &Key, c
return ElxUsedOrNotUsed::NotUsed;
}
FKey UlxUtilityLibrary::GetKeyByName(const FName &Name)
{
FKey Key = FKey(Name);
return Key.IsValid() ? Key : FKey();
}
FKey UlxUtilityLibrary::GetKeyByNameString(const FString &Name)
{
FKey Key = FKey(FName(*Name));
return Key.IsValid() ? Key : FKey();
}

View File

@@ -140,4 +140,18 @@ public:
//
UFUNCTION(BlueprintCallable, Category = "Input", meta = (ExpandEnumAsExecs="ReturnValue"))
static ElxUsedOrNotUsed IsKeyUsedByMappingContext(const FKey &Key, const UInputMappingContext *MappingContext);
// Get a key by name.
//
// Returns the null key if there is no such key.
//
UFUNCTION(BlueprintPure, Category = "Input|Key")
static FKey GetKeyByName(const FName &Name);
// Get a key by name string.
//
// Returns the null key if there is no such key.
//
UFUNCTION(BlueprintPure, Category = "Input|Key")
static FKey GetKeyByNameString(const FString &Name);
};

View File

@@ -19,15 +19,15 @@ function engio.move(action, xyz, facing)
end
function cube.lookhotkeys(keys)
keys:add("X", "Cube Hi", function () dprint("Cube Hi") end)
keys:add("A", "Cube Bye", function () dprint("Cube Bye") end)
keys:add("Y", "Cube Yo", function () dprint("Cube Yo") end)
keys:add("Z", "Cube Hi", function () dprint("Doing Cube Hi") end)
keys:add("X", "Cube Bye", function () dprint("Doing Cube Bye") end)
keys:add("C", "Cube Yo", function () dprint("Doing Cube Yo") end)
end
function sphere.lookhotkeys(keys)
keys:add("X", "Sphere Hi", function () dprint("Sphere Hi") end)
keys:add("A", "Sphere Bye", function () dprint("Sphere Bye") end)
keys:add("Y", "Sphere Yo", function () dprint("Sphere Yo") end)
keys:add("Z", "Sphere Hi", function () dprint("Doing Sphere Hi") end)
keys:add("X", "Sphere Bye", function () dprint("Doing Sphere Bye") end)
keys:add("C", "Sphere Yo", function () dprint("Doing Sphere Yo") end)
end
@@ -58,3 +58,19 @@ function engio.getlookat()
return ""
end
function engio.presshotkey(action)
local class = tangible.getclass(tangible.place())
-- if the tangible doesn't have a 'lookhotkeys' function, do nothing
if class == nil or class.lookhotkeys == nil then
return
end
local press = hotkeypress.create(action)
class.lookhotkeys(press)
local closure = press.closure
if closure ~= nil then
closure()
end
end