185 lines
7.2 KiB
C++
185 lines
7.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
|
#include "cppFuncLibrary.generated.h"
|
|
|
|
/**
|
|
*
|
|
*/
|
|
|
|
USTRUCT(BlueprintType)
|
|
struct FcppflatStruct
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "FlatId", MakeStructureDefaultValue = "-1"))
|
|
int32 FlatId;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "flatType", MakeStructureDefaultValue = "0"))
|
|
int32 flatType;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Flat#", MakeStructureDefaultValue = "-1"))
|
|
int32 FlatN;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Zone", MakeStructureDefaultValue = "-1"))
|
|
int32 Zone;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "House", MakeStructureDefaultValue = "-1"))
|
|
int32 House;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Section", MakeStructureDefaultValue = "-1"))
|
|
int32 Section;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Floor", MakeStructureDefaultValue = "-1"))
|
|
int32 Floor;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Rooms", MakeStructureDefaultValue = "-1"))
|
|
int32 Rooms;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Square", MakeStructureDefaultValue = "0.000000"))
|
|
double Square;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Price", MakeStructureDefaultValue = "0"))
|
|
int32 Price;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "whitePrice", MakeStructureDefaultValue = "0"))
|
|
int32 whitePrice;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "price-meter", MakeStructureDefaultValue = "0"))
|
|
int32 price_meter;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "available", MakeStructureDefaultValue = "True"))
|
|
bool available;
|
|
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "tags"))
|
|
TArray<bool> tags;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "deadline"))
|
|
FIntPoint deadline;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "comment"))
|
|
FString comment;
|
|
};
|
|
|
|
|
|
UCLASS()
|
|
class GRAFFMODULE_API UcppFuncLibrary : public UBlueprintFunctionLibrary
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
UFUNCTION(blueprintcallable)
|
|
static TArray<FString> cppUniversalParser(FString string, TArray<FString> keys, FString delimiter, bool caseSensitive);
|
|
|
|
UFUNCTION(blueprintcallable, BlueprintPure, category = "Math|Integer")
|
|
static FString cppIntToStrPad(int32 int_, int32 minDigits);
|
|
UFUNCTION(blueprintcallable, BlueprintPure)
|
|
static TSoftObjectPtr<UTexture2D> castSoftTex2D(TSoftObjectPtr<UObject> ptr);
|
|
|
|
|
|
UFUNCTION(blueprintcallable, BlueprintPure, category = "Math|Float", meta = (CompactNodeTitle = "*-1"))
|
|
static double NegateF(double in);
|
|
|
|
UFUNCTION(blueprintcallable, BlueprintPure, category = "Math|Integer", meta = (CompactNodeTitle = "*-1"))
|
|
static int32 NegateI(int32 in);
|
|
|
|
|
|
UFUNCTION(blueprintcallable, BlueprintPure, category = "Math|Float", meta = (CompactNodeTitle = "1-x"))
|
|
static double OneMinus(double in);
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, category = "Math|Float", meta = (CompactNodeTitle = "A+=B"))
|
|
static double AddRefF(UPARAM(ref) double& A, double B);
|
|
|
|
UFUNCTION(BlueprintCallable, category = "Math|Integer", meta = (CompactNodeTitle = "A+=B"))
|
|
static int32 AddRefI(UPARAM(ref) int32& A, int32 B);
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, category = "Math|Float", meta = (CompactNodeTitle = "A-=B"))
|
|
static double SubRefF(UPARAM(ref) double& A, double B);
|
|
|
|
UFUNCTION(BlueprintCallable, category = "Math|Integer", meta = (CompactNodeTitle = "A-=B"))
|
|
static int32 SubRefI(UPARAM(ref) int32& A, int32 B);
|
|
|
|
/** clamp int from 0 */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, category = "Math|Float", meta = (CompactNodeTitle = "0+"))
|
|
static int32 clamp0(int32 in);
|
|
|
|
/** clamp float 0 to 1 */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, category = "Math|Float", meta = (CompactNodeTitle = "sat"))
|
|
static double saturate(double in);
|
|
|
|
|
|
/** return true if int is in trueInts. Format: 2,3,4-6 */
|
|
UFUNCTION(BlueprintCallable, Category = "Strings", meta = (Keywords = "stringSwitch"))
|
|
static void cppssw(int32 int_, FString trueInts, bool& true_, bool& false_);
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Strings")
|
|
static FString stringAdd(UPARAM(ref) FString& str, FString add);
|
|
|
|
/** find key=value line by line */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, Category = "Strings")
|
|
static void parseOptions(FString SourceString, FString key, FString Delimiter, FString& value, bool& found);
|
|
|
|
|
|
|
|
/** empty string eq -1 */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, Category = "Strings", meta = (CompactNodeTitle = "strInt"))
|
|
static int32 customStringToInt(FString string);
|
|
|
|
/** by default rule is OR */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, Category = "Strings")
|
|
static void multiContains(FString source, UPARAM(ref) TArray<FString>& substrings, bool bAnd, bool bUseCase, bool& bTrue, bool& bFalse);
|
|
|
|
|
|
|
|
/** return first index of found key and bool arr */
|
|
UFUNCTION(BlueprintCallable, Category = "Strings")
|
|
static void containStringSwitch(FString string, UPARAM(ref) TArray<FString>& keys, bool bUseCase, int32& bInt, TArray<bool>& bools);
|
|
|
|
/** remove substrings from string (replace to "") */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, Category = "Strings")
|
|
static FString multiRemove(FString source, UPARAM(ref) TArray<FString>& substrings, bool bUseCase);
|
|
|
|
/** string->"string" */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, Category = "Strings", meta = (CompactNodeTitle = "\"str\""))
|
|
static FString quoteString(FString string);
|
|
|
|
/** return value*minmult and value*maxmult */
|
|
UFUNCTION(blueprintcallable, BlueprintPure, category = "Math|Float", meta = (Keywords = "minmax"))
|
|
static void getRange(double value, double minMult, double maxMult, double& bMin, double& bValue, double& bMax);
|
|
|
|
/*sortType: 0.price min-to-max 1. max-to-min 2.square min-to-max 3. max-to-min 4.floor min-to-max 5. max-to-min
|
|
use housemap to remap houses array to house-section pair. example: 0:1,1 1:2,1 2:2,2...
|
|
sections array will be ignored if using housemap*/
|
|
UFUNCTION(blueprintcallable, category = "Widget|Search", meta = (WorldContext = "WorldContextObject"))
|
|
static void updateFilterList(UObject* WorldContextObject, int floorMin, int floorMax, float sqMin, float sqMax, int priceMin, int priceMax, int zone, TArray<bool> houses, TArray<bool> sections, TArray<bool> rooms, TArray<bool> Tags, int sortType, bool onlyAvailable, TArray<FcppflatStruct>& filtered, int& count, TArray<FIntPoint> houseMap);
|
|
/*additional info in comment: n=int;sqFrom=float;sqTo=float*/
|
|
UFUNCTION(blueprintcallable, category = "Widget|Search")
|
|
static void groupFiltered(UPARAM(ref) TArray<FcppflatStruct>& filtered, UPARAM(ref) TArray<FcppflatStruct>& filtered_grouped);
|
|
|
|
private:
|
|
|
|
static bool inRange(float in, float min, float max);
|
|
static bool inRange(int in, int min, int max);
|
|
/*return true if no true in array*/
|
|
static bool boolGet(TArray<bool> arr, int index);
|
|
static void minmaxInRange(TArray<int>arr, int min, int max, int& minid, int& maxid);
|
|
static void minmaxInRange(TArray<float>arr, int min, int max, int& minid, int& maxid);
|
|
}; |