////////////////////////////////////////////////////////////
//
// Common.h
//
// Simple data types used throughout the Unreal
// interface to Luprex: type aliases, blueprint
// enums for branching, and log categories.
//
////////////////////////////////////////////////////////////

#pragma once

#include <string_view>
#include "lpx-basebuffer.hpp"
#include "Blueprint/UserWidget.h"
#include "Common.generated.h"

////////////////////////////////////////////////////////////
//
// LpxCommonTypes
//
// Type aliases used throughout the integration.
//
////////////////////////////////////////////////////////////

namespace LpxCommonTypes {
	// Array of tangible IDs.
	//
	using IdArray = TArray<int64>;

	// View of Array of tangible IDs.
	//
	using IdView = TArrayView<const int64>;

	// Array of std::string_view.
	//
	using StringViewVec = TArray<std::string_view>;
}

////////////////////////////////////////////////////////////
//
// ElxLuaValueType
//
// Mirror of LuaValueType from base-buffer.hpp.
// Values must match one-for-one. Note that "token"
// has been renamed to "name" (synonymous).
//
////////////////////////////////////////////////////////////

UENUM(BlueprintType)
enum class ElxLuaValueType : uint8 {
    End,
    String,
	Name,
    Float,
    Boolean,
    Vector
};

struct LuaValue : BaseLuaValue<std::string>
{
    ElxLuaValueType GetElxType() const { return static_cast<ElxLuaValueType>(type); }
    void SetElxType(ElxLuaValueType t) { type = static_cast<LuaValueType>(t); }
};

////////////////////////////////////////////////////////////
//
// Branching Enums
//
// Boolean-like results used with ExpandEnumAsExecs
// to create branching blueprint functions.
//
////////////////////////////////////////////////////////////

UENUM(BlueprintType)
enum class ElxSuccessOrError : uint8 {
	Success,
	Error,
};

UENUM(BlueprintType)
enum class ElxValidOrNotValid : uint8 {
	Valid,
	NotValid,
};

UENUM(BlueprintType)
enum class ElxFoundOrNotFound : uint8 {
	Found,
	NotFound,
};

UENUM(BlueprintType)
enum class ElxUsedOrNotUsed : uint8 {
	Used,
	NotUsed,
};

UENUM(BlueprintType)
enum class ElxSuccessOrWrongType : uint8 {
	Success,
	WrongType,
};

////////////////////////////////////////////////////////////
//
// ElxLuaSyntaxCheck
//
// Classifies console commands syntactically:
//
//   SlashCommand: starts with a slash, not lua
//   Whitespace: the input only contains whitespace
//   ValidLua: the input is valid lua code
//   TruncatedLua: the input is truncated
//   InvalidLua: invalid lua
//
////////////////////////////////////////////////////////////

UENUM(BlueprintType)
enum class ElxLuaSyntaxCheck : uint8 {
	SlashCommand,
	Whitespace,
	ValidLua,
	TruncatedLua,
	InvalidLua,
};

////////////////////////////////////////////////////////////
//
// ElxControllerType
//
// The three types of controller recognized by luprex.
//
////////////////////////////////////////////////////////////

UENUM(BlueprintType)
enum class ElxControllerType : uint8 {
	KeyboardMouse,
	XboxGamepad,
	PlayStationGamepad,
};

////////////////////////////////////////////////////////////
//
// Log Categories
//
////////////////////////////////////////////////////////////

// Messages from inside the Luprex Core.
//
DECLARE_LOG_CATEGORY_EXTERN(LogLuprex, Display, All);

// Messages about the Luprex integration with Unreal.
//
DECLARE_LOG_CATEGORY_EXTERN(LogLuprexIntegration, Display, All);

// Messages from the Luprex console.
//
DECLARE_LOG_CATEGORY_EXTERN(LogLuprexConsole, Display, All);
