обновы какие то

This commit is contained in:
2024-07-02 18:54:36 +05:00
parent 87bcdc6242
commit f8cb05c514
175 changed files with 317 additions and 131 deletions
@@ -0,0 +1,12 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "RichTextBlockPerc.h"
void URichTextBlockPerc::setLineHeightPercentage(float newPerc)
{
LineHeightPercentage = newPerc;
SynchronizeProperties();
}
+124 -8
View File
@@ -2,9 +2,29 @@
#include "cppFuncLibrary.h"
#include "cppGI.h"
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetStringLibrary.h"
#include "Kismet/KismetTextLibrary.h"
#include "Kismet/KismetmathLibrary.h"
bool operator==(const Fcppcoords c1, const Fcppcoords c2) {
return c1.flat == c2.flat &&
c1.floor == c2.floor &&
c1.house == c2.house &&
c1.section == c2.section &&
c1.type == c2.type &&
c1.zone == c2.zone;
}
//
//bool operator==(const FcppLevelStruct& c1, const FcppLevelStruct& c2) {
// return c1.anotherLvl == c2.anotherLvl &&
// c1.coords == c2.coords &&
// c1.dontUnload == c2.dontUnload &&
// c1.path == c2.path &&
// c1.uniqName == c2.uniqName &&
// c1.Z == c2.Z;
//}
TArray<FString> UcppFuncLibrary::cppUniversalParser(FString string, TArray<FString> keys, FString delimiter, bool caseSensitive)
{
@@ -201,7 +221,7 @@ FString UcppFuncLibrary::multiRemove(FString source, UPARAM(ref)TArray<FString>&
FString UcppFuncLibrary::quoteString(FString string)
{
return FString("""").Append(string).Append("""");
return FString("\"").Append(string).Append("\"");
}
void UcppFuncLibrary::getRange(double value, double minMult, double maxMult, double& bMin, double& bValue, double& bMax)
@@ -211,18 +231,48 @@ 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, bool onlyAvailable, TArray<FcppflatStruct>& filtered, int& count)
void UcppFuncLibrary::updateFilterList(UObject* WorldContextObject, int floorMin, int floorMax, float sqMin, float sqMax, int priceMin, int priceMax, TArray<bool> houses, TArray<bool> sections, TArray<bool> rooms, TArray<bool> Tags, int sortType, bool onlyAvailable, TArray<FcppflatStruct>& filtered, int& count, TArray<FIntPoint> houseMap)
{
for (auto& hm : houseMap) {
}
auto gi = StaticCastPtr<UcppGI, UGameInstance>(UGameplayStatics::GetGameInstance(WorldContextObject));
if (!gi) return;
TArray<int> tempfloor, tempprice;
TArray<float> tempsq;
for (auto& flat : flats) {
for (auto& flat : gi->flatArray) {
if (inRange(flat.Floor, floorMin, floorMax)
&& inRange(flat.Price, priceMin, priceMax)
&& inRange(flat.Square, sqMin, sqMax)
&& boolGet(houses, flat.House)
&& boolGet(sections, flat.Section)
&& boolGet(rooms, flat.Rooms)
&& (onlyAvailable?flat.available:true)) {
//&& boolGet(houses, flat.House)
//&& boolGet(sections, flat.Section)
&& [](TArray<FIntPoint>& houseMap_, TArray<bool>& houses_, TArray<bool>& sections_, FcppflatStruct& flat_) {
if (houseMap_.IsEmpty()) return boolGet(houses_, flat_.House) && boolGet(sections_, flat_.Section); //if no map use classic
if (!houses_.Contains(true)) return true; //if no select then pass
for (int n = 0; n < houses_.Num(); n++) {
if (houseMap_.IsValidIndex(n)) {
if (houseMap_[n].X == flat_.House && houseMap_[n].Y == flat_.Section) return houses_[n];
}
}
return false;
}(houseMap, houses, sections, flat)
&& boolGet(rooms, flat.Rooms)
&& [](TArray<bool> tags, TArray<bool> ftags) {
int n = 0;
for (auto& t : tags) {
if (ftags.IsValidIndex(n))
{
if (t && !ftags[n]) return false;
}
n++;
}
return true;
}(Tags, flat.tags)
&& (onlyAvailable ? flat.available : true)) {
filtered.Add(flat);
tempfloor.Add(flat.Floor);
tempprice.Add(flat.Price);
@@ -274,6 +324,73 @@ void UcppFuncLibrary::updateFilterList(TArray<FcppflatStruct> flats, int floorMi
}
}
void UcppFuncLibrary::groupFiltered(UPARAM(ref)TArray<FcppflatStruct>& filtered, UPARAM(ref)TArray<FcppflatStruct>& filtered_grouped)
{
TArray<Fcppcoords> filteredCoords;
for (auto& f : filtered) {
filteredCoords.Add(Fcppcoords(f.FlatId, f.flatType, f.Zone, f.House, f.Section));
}
TArray<Fcppcoords> filtered_grCoords;
//for (auto& f : filtered_grouped) {
// Fcppcoords ff;
// ff.flat = f.FlatId;
// ff.house = f.House;
// ff.section = f.Section;
// ff.type = f.flatType;
// ff.zone = f.Zone;
// //skip floor
// filtered_grCoords.Add(ff);
//}
filtered_grouped.Empty();
int nn = 0;
for (auto& obj : filtered) {
if (filtered_grCoords.Contains(filteredCoords[nn])) {
auto fc = filtered_grCoords.Find(filteredCoords[nn]);
FJsonSerializableArray opts;
filtered_grouped[fc].comment.ParseIntoArray(opts, L";");
FString l;
FString r;
opts[0].Split(L"=", &l, &r);
//auto cn = FCString::Atoi(*r); //current N
auto cn = UKismetStringLibrary::Conv_StringToInt(r);
opts[1].Split(L"=", &l, &r);
//auto csqf=FCString::Atof(*r);// current sqfrom
auto csqf = UKismetStringLibrary::Conv_StringToFloat(r);
opts[2].Split(L"=", &l, &r);
//auto csqt=FCString::Atof(*r);// current sqto
auto csqt = UKismetStringLibrary::Conv_StringToFloat(r);
cn++;
csqt = obj.Square > csqt ? obj.Square : csqt;
csqf = obj.Square < csqf ? obj.Square : csqf;
if (filtered_grouped[fc].Price > obj.Price) filtered_grouped[fc].Price = obj.Price;
filtered_grouped[fc].comment =
L"n="
+ FString::FromInt(cn)
+ L";sqfrom="
+ UKismetTextLibrary::Conv_FloatToText(csqf, ERoundingMode::HalfToEven, false, false, 1, 5, 2, 2).ToString()
+ L";sqto="
+ UKismetTextLibrary::Conv_FloatToText(csqt, ERoundingMode::HalfToEven, false, false, 1, 5, 2, 2).ToString();
filtered_grouped[fc].comment.ReplaceCharInline(*L",", *L".");
obj.comment = filtered_grouped[fc].comment;
//here is place for your commercial
}
else {
obj.comment = L"n=1;sqfrom="
+ UKismetTextLibrary::Conv_FloatToText(obj.Square, ERoundingMode::HalfToEven, false, false, 1, 5, 2, 2).ToString()
+ L";sqto="
+ UKismetTextLibrary::Conv_FloatToText(obj.Square, ERoundingMode::HalfToEven, false, false, 1, 5, 2, 2).ToString();
obj.comment.ReplaceCharInline(*L",", *L"."); //parser dont understand , lol
//UE_LOG(LogTemp, Warning, TEXT("start sq %f, txt %s"), obj.Square, *obj.comment);
filtered_grouped.Add(obj);
filtered_grCoords.Add(Fcppcoords(obj.FlatId, obj.flatType, obj.Zone, obj.House, obj.Section));
}
nn++;
}
}
bool UcppFuncLibrary::inRange(float in, float min, float max)
{
return (in >= min) && (in <= max);
@@ -324,4 +441,3 @@ void UcppFuncLibrary::minmaxInRange(TArray<float> arr, int min, int max, int& mi
+13 -46
View File
@@ -145,15 +145,15 @@ TArray<FcppflatStruct> UcppGI::getFlatArr_(Fcppcoords coords, int& len)
auto output = TArray<FcppflatStruct>();
for (auto& flat : flatArray) {
auto flatcoords = Fcppcoords();
flatcoords.flat = coords.flat < 0 ? -2 : flat.FlatId; //ignore flat
flatcoords.floor = coords.floor < 0 ? -2 : flat.Floor;
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, boolDummy, boolDummy, boolDummy, boolDummy, boolDummy, boolDummy, 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();
@@ -166,27 +166,21 @@ FcppflatStruct UcppGI::findFlatByCoords_(Fcppcoords coords, bool& success)
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();
if (len>1) UE_LOG(LogCore, Warning, TEXT("UcppGI::findFlatByCoords: found more than one flat: GP%d-S%d-F%d-A%d"),coords.house,coords.section,coords.floor,coords.flat);
if (len==0) return FcppflatStruct();
success = true;
return tt[0];
}
FcppflatStruct UcppGI::findFlatByN_(Fcppcoords filter, int num, bool& success)
TArray<FcppflatStruct> UcppGI::findFlatsByN_(int num, bool& success)
{
success = false;
filter.flat = -2;
auto output = FcppflatStruct();
auto arr = getFlatArr_(filter, intDummy);
for (auto& flat : arr) {
if (flat.FlatN == num) {
if (!success) output = flat;
else UE_LOG(LogCore, Warning, TEXT("UcppGI::findFlatByN_: found more than one flat"));
success = true;
}
auto output = TArray<FcppflatStruct>();
for (auto& flat : flatArray) {
if (flat.FlatN == num) output.Add(flat);
}
success = !output.IsEmpty();
return output;
}
@@ -195,7 +189,7 @@ void UcppGI::countFreeApartments(Fcppcoords coords, int& free, int& all, float&
int len;
free = 0;
minPrice = 0;
bool temp = false;
bool temp=false;
for (auto& flat : getFlatArr_(coords, len)) {
if (flat.available) {
if (!temp) {
@@ -211,30 +205,3 @@ void UcppGI::countFreeApartments(Fcppcoords coords, int& free, int& all, float&
return;
}
void UcppGI::cppFlatTocppCoords(FcppflatStruct flat, Fcppcoords& coords)
{
coords.flat = flat.FlatId;
coords.floor = flat.Floor;
coords.house = flat.House;
coords.section = flat.Section;
coords.type = flat.flatType;
coords.zone = flat.Zone;
}
void UcppGI::cppCoordsToCppFlat(UObject* WorldContextObject, Fcppcoords coords, FcppflatStruct& flat, bool onlyCoords)
{
if (onlyCoords) {
flat.FlatId = coords.flat;
flat.Floor = coords.floor;
flat.House = coords.house;
flat.Section = coords.section;
flat.flatType = coords.type;
flat.Zone = coords.zone;
return;
}
bool dum;
flat = StaticCastPtr<UcppGI,UGameInstance>(UGameplayStatics::GetGameInstance(WorldContextObject))->findFlatByCoords_(coords, dum);
}