-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for reading array properties, at last
- Loading branch information
Showing
7 changed files
with
139 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 42 additions & 5 deletions
47
src/main/java/net/shrimpworks/unreal/packages/entities/properties/ArrayProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,57 @@ | ||
package net.shrimpworks.unreal.packages.entities.properties; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import net.shrimpworks.unreal.packages.Package; | ||
import net.shrimpworks.unreal.packages.entities.Name; | ||
import net.shrimpworks.unreal.packages.entities.ObjectReference; | ||
|
||
public class ArrayProperty extends Property { | ||
|
||
public final ObjectReference arrayType; | ||
public final List<Property> values; | ||
|
||
public ArrayProperty(Property initialValue) { | ||
this(initialValue.pkg, initialValue.name, List.of(initialValue)); | ||
} | ||
|
||
public ArrayProperty(Package pkg, Name name, ObjectReference arrayType) { | ||
public ArrayProperty(Package pkg, Name name, List<Property> values) { | ||
super(pkg, name); | ||
this.arrayType = arrayType; | ||
this.values = Collections.unmodifiableList(values); | ||
} | ||
|
||
public ArrayProperty add(ArrayItem value) { | ||
List<Property> nextValues = new ArrayList<>(values); | ||
nextValues.add(Math.min(value.index, nextValues.size()), value.property); | ||
return new ArrayProperty(pkg, name, nextValues); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("ArrayProperty [name=%s, arrayType=%s]", name, arrayType); | ||
return String.format("ArrayProperty [name=%s, values=%s]", name, values); | ||
} | ||
|
||
/** | ||
* A special magical transitional item which represents an element within | ||
* an array. | ||
* <p> | ||
* The Package managing this property should unwrap the property within | ||
* and add it to an ArrayProperty. | ||
*/ | ||
public static class ArrayItem extends Property { | ||
|
||
public final Property property; | ||
public final int index; | ||
|
||
public ArrayItem(Property property, int index) { | ||
super(property.pkg, property.name); | ||
this.property = property; | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("ArrayItem [index=%s, property=%s]", index, property); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/net/shrimpworks/unreal/packages/entities/properties/UnknownArrayProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.shrimpworks.unreal.packages.entities.properties; | ||
|
||
import net.shrimpworks.unreal.packages.Package; | ||
import net.shrimpworks.unreal.packages.entities.Name; | ||
import net.shrimpworks.unreal.packages.entities.ObjectReference; | ||
|
||
/** | ||
* This is a property type defined by {@link PropertyType#ArrayProperty}, | ||
* identified as property type 9. | ||
* <p> | ||
* However, there's no documentation for this type, and it appears to | ||
* be something that was never actually implemented or used, since array | ||
* properties are simply regular properties, with indexes and things | ||
* defined by the property header. | ||
*/ | ||
public class UnknownArrayProperty extends Property { | ||
|
||
public final ObjectReference arrayType; | ||
|
||
public UnknownArrayProperty(Package pkg, Name name, ObjectReference arrayType) { | ||
super(pkg, name); | ||
this.arrayType = arrayType; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("ArrayProperty [name=%s, arrayType=%s]", name, arrayType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters