void AttributeSubjectMap::SetAtts(const int index, const AttributeSubject *attr, int &i0, int &i1) { int i; for (i = 0; i < nIndices && indices[i] < index; ++i) ; // // If the index matches an existing index exactly then replace // the attributes for it, otherwise insert it in the list. // if (i < nIndices && indices[i] == index) { atts[i]->CopyAttributes(attr); } else { int j; // // Increase the length of the list if we need to. // if (nIndices == maxIndices) { ResizeMap(maxIndices+MAP_INCR); } // // Insert the item in the list. // for (j = nIndices; j > i; --j) { atts[j] = atts[j-1]; indices[j] = indices[j-1]; } atts[i] = attr->NewInstance(true); indices[i] = index; nIndices++; } // // Determine the range of attributes invalidated. // if (i - 1 < 0) i0 = 0; else i0 = indices[i-1] + 1; if (i + 1 < nIndices) i1 = indices[i+1] - 1; else i1 = INT_MAX; }
void UPaperTileMap::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; //@TODO: Determine when these are really needed, as they're seriously expensive! FTileMapReregisterContext ReregisterTileMapComponents(this); ValidateSelectedLayerIndex(); if (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperTileMap, HexSideLength)) { HexSideLength = FMath::Max<int32>(HexSideLength, 0); // The side length needs to be included in the overall tile height TileHeight += HexSideLength; } TileWidth = FMath::Max(TileWidth, 1); TileHeight = FMath::Max(TileHeight, 1); MapWidth = FMath::Max(MapWidth, 1); MapHeight = FMath::Max(MapHeight, 1); if (PixelsPerUnrealUnit <= 0.0f) { PixelsPerUnrealUnit = 1.0f; } if ((PropertyName == GET_MEMBER_NAME_CHECKED(UPaperTileMap, MapWidth)) || (PropertyName == GET_MEMBER_NAME_CHECKED(UPaperTileMap, MapHeight))) { ResizeMap(MapWidth, MapHeight, /*bForceResize=*/ true); } else { // Make sure that the layers are all of the right size for (UPaperTileLayer* TileLayer : TileLayers) { if ((TileLayer->GetLayerWidth() != MapWidth) || (TileLayer->GetLayerHeight() != MapHeight)) { TileLayer->Modify(); TileLayer->ResizeMap(MapWidth, MapHeight); } } } if (!IsTemplate()) { UpdateBodySetup(); } Super::PostEditChangeProperty(PropertyChangedEvent); }
bool AttributeSubjectMap::CopyAttributes(const AttributeSubjectMap *attr) { // // If we don't have any attributes, we can't copy them. // if (nIndices <= 0 || attr == NULL || attr->nIndices <= 0) return false; // // Try copying the first attributes to determine if the individual // attributes can be copied. // if (!atts[0]->CopyAttributes(attr->atts[0])) return false; indices[0] = attr->indices[0]; // // Resize the map if necessary. // if (maxIndices < attr->nIndices) { ResizeMap(attr->maxIndices); } // // Copy the map. Delete any excess AttributeSubjects if there were // fewer indices in the source than in the destination. // int i; for (i = 1; i < attr->nIndices; ++i) { if (i >= nIndices) atts[i] = attr->CreateCompatible(attr->atts[i]->TypeName()); atts[i]->CopyAttributes(attr->atts[i]); indices[i] = attr->indices[i]; } for (; i < nIndices; ++i) { delete atts[i]; } nIndices = attr->nIndices; return true; }