This commit is contained in:
2024-03-07 20:43:00 +05:00
parent b73c581832
commit b9a1f27817
53 changed files with 112 additions and 18 deletions
@@ -211,7 +211,7 @@ void UcppFuncLibrary::getRange(double value, double minMult, double maxMult, dou
bValue = value;
}
void UcppFuncLibrary::updateFilterList(TArray<FcppflatStruct> flats, int floorMin, int floorMax, float sqMin, float sqMax, int priceMin, int priceMax, TArray<bool> houses, TArray<bool> sections, TArray<bool> rooms, int sortType, TArray<FcppflatStruct>& filtered)
void UcppFuncLibrary::updateFilterList(TArray<FcppflatStruct> flats, int floorMin, int floorMax, float sqMin, float sqMax, int priceMin, int priceMax, TArray<bool> houses, TArray<bool> sections, TArray<bool> rooms, int sortType, bool onlyAvailable, TArray<FcppflatStruct>& filtered, int& count)
{
TArray<int> tempfloor, tempprice;
TArray<float> tempsq;
@@ -221,13 +221,15 @@ void UcppFuncLibrary::updateFilterList(TArray<FcppflatStruct> flats, int floorMi
&& inRange(flat.Square, sqMin, sqMax)
&& boolGet(houses, flat.House)
&& boolGet(sections, flat.Section)
&& boolGet(rooms, flat.Rooms)) {
&& boolGet(rooms, flat.Rooms)
&& (onlyAvailable?flat.available:true)) {
filtered.Add(flat);
tempfloor.Add(flat.Floor);
tempprice.Add(flat.Price);
tempsq.Add(flat.Square);
}
}
count = filtered.Num();
if (tempfloor.Num() > 1) {
switch (sortType) {
case 0:
+67
View File
@@ -112,6 +112,8 @@ TArray<ULevelStreaming*> UcppGI::cppLvlManage(UObject* WorldContextObject, Fcppc
void UcppGI::cppCoordsEq(Fcppcoords coords, Fcppcoords coords1, bool relevantMinus2, bool fastEq, bool& flat_, bool& type_, bool& zone_, bool& house_, bool& section_, bool& floor_, bool& fullEq)
{
bool* outLvl[6] = { &flat_, &type_, &zone_, &house_, &section_, &floor_ };
@@ -138,3 +140,68 @@ void UcppGI::cppCoordsEq(Fcppcoords coords, Fcppcoords coords1, bool relevantMin
}
TArray<FcppflatStruct> UcppGI::getFlatArr_(Fcppcoords coords, int& len)
{
auto output = TArray<FcppflatStruct>();
for (auto& flat : flatArray) {
auto flatcoords = Fcppcoords();
flatcoords.flat = coords.floor < 0 ? -2 : flat.FlatId; //ignore flat
flatcoords.floor =coords.floor<0?-2: flat.Floor;
flatcoords.house = coords.house < 1 ? -2 : flat.House;
flatcoords.section = coords.section < 1 ? -2 : flat.Section;
flatcoords.type = coords.type < 0 ? -2 : flat.flatType;
flatcoords.zone = coords.zone < 1 ? -2 : flat.Zone;
bool dummy[6];
bool eq;
cppCoordsEq(coords, flatcoords, true, false, dummy[0], dummy[1], dummy[2], dummy[3], dummy[4], dummy[5], eq);
if (eq) output.Add(flat);
}
len = output.Num();
return output;
}
FcppflatStruct UcppGI::findFlatByCoords_(Fcppcoords coords, bool& success)
{
success = false;
if (coords.flat < 0) return FcppflatStruct();
int len;
auto tt = getFlatArr_(coords, len);
if (len>1) UE_LOG(LogCore, Warning, TEXT("UcppGI::findFlatByCoords: found more than one flat"));
if (len==0) return FcppflatStruct();
success = true;
return tt[0];
}
TArray<FcppflatStruct> UcppGI::findFlatsByN_(int num, bool& success)
{
success = false;
auto output = TArray<FcppflatStruct>();
for (auto& flat : flatArray) {
if (flat.FlatN == num) output.Add(flat);
}
success = !output.IsEmpty();
return output;
}
void UcppGI::countFreeApartments(Fcppcoords coords, int& free, int& all, float& minPrice)
{
int len;
free = 0;
minPrice = 0;
bool temp=false;
for (auto& flat : getFlatArr_(coords, len)) {
if (flat.available) {
if (!temp) {
minPrice = flat.Price;
temp = true;
}
free++;
if (flat.Price < minPrice) minPrice = flat.Price;
}
}
minPrice /= 1000000;
all = len;
return;
}
+20 -15
View File
@@ -15,59 +15,64 @@ struct FcppflatStruct
{
GENERATED_BODY()
public:
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "FlatId", MakeStructureDefaultValue = "-1"))
int32 FlatId;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "flatType", MakeStructureDefaultValue = "0"))
int32 flatType;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Flat#", MakeStructureDefaultValue = "-1"))
int32 FlatN;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Zone", MakeStructureDefaultValue = "-1"))
int32 Zone;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "House", MakeStructureDefaultValue = "-1"))
int32 House;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Section", MakeStructureDefaultValue = "-1"))
int32 Section;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Floor", MakeStructureDefaultValue = "-1"))
int32 Floor;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Rooms", MakeStructureDefaultValue = "-1"))
int32 Rooms;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Square", MakeStructureDefaultValue = "0.000000"))
double Square;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "Price", MakeStructureDefaultValue = "0"))
int32 Price;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "whitePrice", MakeStructureDefaultValue = "0"))
int32 whitePrice;
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "price-meter", MakeStructureDefaultValue = "0"))
int32 price_meter;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "available", MakeStructureDefaultValue = "True"))
bool available;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "tags"))
TArray<bool> tags;
/** Please add a variable description */
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "deadline"))
FIntPoint deadline;
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (DisplayName = "comment"))
FString comment;
};
@@ -162,7 +167,7 @@ class GRAFFMODULE_API UcppFuncLibrary : public UBlueprintFunctionLibrary
/*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*/
UFUNCTION(blueprintcallable, category = "Widget|Search")
static void updateFilterList(TArray<FcppflatStruct> flats, int floorMin, int floorMax, float sqMin, float sqMax, int priceMin, int priceMax, TArray<bool> houses, TArray<bool> sections, TArray<bool> rooms, int sortType, TArray<FcppflatStruct>& filtered);
static void updateFilterList(TArray<FcppflatStruct> flats, int floorMin, int floorMax, float sqMin, float sqMax, int priceMin, int priceMax, TArray<bool> houses, TArray<bool> sections, TArray<bool> rooms, int sortType, bool onlyAvailable, TArray<FcppflatStruct>& filtered, int& count);
private:
+21 -1
View File
@@ -61,7 +61,24 @@ public:
/*returns array of levels for binding*/
UFUNCTION(blueprintcallable, Category = "LevelLoading", meta = (WorldContext = "WorldContextObject"))
TArray<ULevelStreaming*> cppLvlManage(UObject* WorldContextObject, Fcppcoords currentCoords, uint8 currentState);
/*return array filtered by coords, coord<0 for floor and <1 for other is ignore the one*/
UFUNCTION(blueprintcallable, category = "Data")
TArray<FcppflatStruct> getFlatArr_(Fcppcoords coords, int& len);
UFUNCTION(blueprintcallable, category = "Data")
FcppflatStruct findFlatByCoords_(Fcppcoords coords, bool& success);
/*return array with flats with specified number
(may be from different houses if not sequetnal numeration)*/
UFUNCTION(blueprintcallable, category = "Data")
TArray<FcppflatStruct> findFlatsByN_(int num, bool& success);
/*coord=-2 is ignore the one, price is millions*/
UFUNCTION(blueprintcallable, category = "Data")
void countFreeApartments(Fcppcoords coords,int& free,int& all,float& minPrice);
/*list of lvls for anyway loading*/
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "levelLoading")
TArray<FcppLevelStruct> cppWhiteList;
@@ -80,6 +97,9 @@ public:
/*list of lvls struct created by levelloader*/
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "levelLoading")
TArray<FcppLevelStruct> cppLevels;
/*list of all flats in project*/
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Data")
TArray<FcppflatStruct> flatArray;