-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement some more handlers for HFW types
- Loading branch information
1 parent
db337ec
commit 777417c
Showing
5 changed files
with
84 additions
and
7 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
31 changes: 31 additions & 0 deletions
31
...src/main/java/com/shade/decima/game/hfw/rtti/callbacks/LocalizedTextResourceCallback.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,31 @@ | ||
package com.shade.decima.game.hfw.rtti.callbacks; | ||
|
||
import com.shade.decima.game.hfw.rtti.HorizonForbiddenWest.ELanguage; | ||
import com.shade.decima.rtti.Attr; | ||
import com.shade.decima.rtti.data.ExtraBinaryDataCallback; | ||
import com.shade.decima.rtti.factory.TypeFactory; | ||
import com.shade.util.NotNull; | ||
import com.shade.util.io.BinaryReader; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class LocalizedTextResourceCallback implements ExtraBinaryDataCallback<LocalizedTextResourceCallback.TranslationData> { | ||
public interface TranslationData { | ||
@Attr(name = "Translations", type = "Array<String>", position = 0, offset = 0) | ||
List<String> translations(); | ||
|
||
void translations(List<String> translations); | ||
} | ||
|
||
@Override | ||
public void deserialize(@NotNull BinaryReader reader, @NotNull TypeFactory factory, @NotNull TranslationData object) throws IOException { | ||
var count = ELanguage.values().length - 1; // Excluding "Unknown" | ||
var translations = new ArrayList<String>(count); | ||
for (int i = 0; i < count; i++) { | ||
translations.add(reader.readString(Short.toUnsignedInt(reader.readShort()))); | ||
} | ||
object.translations(translations); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...n-west/src/main/java/com/shade/decima/game/hfw/rtti/callbacks/ShaderResourceCallback.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,32 @@ | ||
package com.shade.decima.game.hfw.rtti.callbacks; | ||
|
||
import com.shade.decima.game.hfw.rtti.HFWTypeReader; | ||
import com.shade.decima.game.hfw.rtti.HorizonForbiddenWest.MurmurHashValue; | ||
import com.shade.decima.rtti.Attr; | ||
import com.shade.decima.rtti.data.ExtraBinaryDataCallback; | ||
import com.shade.decima.rtti.factory.TypeFactory; | ||
import com.shade.util.NotNull; | ||
import com.shade.util.io.BinaryReader; | ||
|
||
import java.io.IOException; | ||
|
||
public class ShaderResourceCallback implements ExtraBinaryDataCallback<ShaderResourceCallback.ShaderData> { | ||
public interface ShaderData { | ||
@Attr(name = "Hash", type = "MurmurHashValue", position = 0, offset = 0) | ||
MurmurHashValue hash(); | ||
|
||
void hash(MurmurHashValue hash); | ||
|
||
@Attr(name = "Data", type = "uint8", position = 1, offset = 8) | ||
byte[] data(); | ||
|
||
void data(byte[] data); | ||
} | ||
|
||
@Override | ||
public void deserialize(@NotNull BinaryReader reader, @NotNull TypeFactory factory, @NotNull ShaderData object) throws IOException { | ||
var size = reader.readInt(); | ||
object.hash(HFWTypeReader.readCompound(MurmurHashValue.class, reader, factory)); | ||
object.data(reader.readBytes(size)); | ||
} | ||
} |
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