Skip to content

Commit

Permalink
Resolve the binding hash to the shader resource binding name (#70)
Browse files Browse the repository at this point in the history
Added NameHashValueHandler, which creates crc32 lookup table for the
shader resource binding names
Colorized some decorators for better readability

![NameHashValueHandler](https://github.com/ShadelessFox/decima/assets/49768797/555cff3e-ce46-4044-8215-bb25b42f0907)
Extended ModelViewer for *MeshResourcePart types
Extended texture decorator and viewer:
Added selector for "MenuStreamingTexture" and "UITextureBindingOverride"
types

![MultiMeshParts+MenuStreamingTextures](https://github.com/ShadelessFox/decima/assets/49768797/9f22927f-f526-4116-99c6-8452516f9cb0)

---------

Co-authored-by: ShadelessFox <[email protected]>
  • Loading branch information
mithkr and ShadelessFox authored Apr 9, 2024
1 parent 2ae0d26 commit 9b0fc57
Show file tree
Hide file tree
Showing 17 changed files with 549 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

@ValueViewerRegistration({
@Selector(type = @Type(name = "MeshResourceBase")),
@Selector(type = @Type(name = "LodMeshResourcePart")),
@Selector(type = @Type(name = "MultiMeshResourcePart")),
@Selector(type = @Type(name = "ArtPartsDataResource"), game = {GameType.DS, GameType.DSDC}),
@Selector(type = @Type(name = "ArtPartsSubModelResource"), game = {GameType.DS, GameType.DSDC}),
@Selector(type = @Type(name = "ArtPartsSubModelWithChildrenResource"), game = {GameType.DS, GameType.DSDC}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ private static Node serialize(
serializeModelPartResource(task.split(1), node, object, file, project, context);
case "LodMeshResource" ->
serializeLodMeshResource(task.split(1), node, object, file, project, context);
case "LodMeshResourcePart", "MultiMeshResourcePart" ->
serializeMeshResourcePart(task.split(1), node, object, file, project, context);
case "MultiMeshResource" ->
serializeMultiMeshResource(task.split(1), node, object, file, project, context);
case "StaticMeshInstance" ->
Expand Down Expand Up @@ -417,6 +419,17 @@ private static void serializeLodMeshResource(
}
}

private static void serializeMeshResourcePart(
@NotNull ProgressMonitor monitor,
@NotNull Node root,
@NotNull RTTIObject object,
@NotNull RTTICoreFile file,
@NotNull Project project,
@NotNull Context context
) throws IOException {
root.add(serialize(monitor, object.ref("Mesh"), file, project, context));
}

private static void serializeModelPartResource(
@NotNull ProgressMonitor monitor,
@NotNull Node root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
@Selector(type = @Type(name = "ImageMapEntry")),
@Selector(type = @Type(name = "ButtonIcon")),
@Selector(type = @Type(name = "MenuStreamingTexture")),
@Selector(type = @Type(name = "UITextureBindingOverride")),
@Selector(type = @Type(type = HwTexture.class))
})
public class TextureViewer implements ValueViewer {
Expand Down Expand Up @@ -130,7 +131,7 @@ public static TextureInfo getTextureInfo(@NotNull RTTIObject object, @NotNull Pr
case "TextureBindingWithHandle", "ShaderTextureBinding" -> {
return getTextureInfo(object.ref("TextureResource"), project, file, object.i32("PackedData"));
}
case "TextureSetEntry", "ImageMapEntry", "ButtonIcon", "MenuStreamingTexture" -> {
case "TextureSetEntry", "ImageMapEntry", "ButtonIcon", "MenuStreamingTexture", "UITextureBindingOverride" -> {
return getTextureInfo(object.ref("Texture"), project, file, 0);
}
case "TextureSet" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.shade.decima.ui.data.registry.ValueHandlerRegistration;
import com.shade.decima.ui.data.registry.ValueHandlerRegistration.Selector;
import com.shade.decima.ui.data.registry.ValueHandlerRegistration.Type;
import com.shade.platform.ui.controls.TextAttributes;
import com.shade.platform.ui.controls.CommonTextAttributes;
import com.shade.util.NotNull;
import com.shade.util.Nullable;

Expand All @@ -19,7 +19,7 @@ public class GGUUIDValueHandler extends ObjectValueHandler {
@NotNull
@Override
public Decorator getDecorator(@NotNull RTTIType<?> type) {
return (value, component) -> component.append("{%s}".formatted(RTTIUtils.uuidToString((RTTIObject) value)), TextAttributes.REGULAR_ATTRIBUTES);
return (value, component) -> component.append("{%s}".formatted(RTTIUtils.uuidToString((RTTIObject) value)), CommonTextAttributes.NUMBER_ATTRIBUTES);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import com.shade.decima.ui.data.registry.ValueHandlerRegistration;
import com.shade.decima.ui.data.registry.ValueHandlerRegistration.Selector;
import com.shade.decima.ui.data.registry.ValueHandlerRegistration.Type;
import com.shade.platform.ui.controls.TextAttributes;
import com.shade.platform.ui.controls.CommonTextAttributes;
import com.shade.util.NotNull;
import com.shade.util.Nullable;

import javax.swing.*;

@ValueHandlerRegistration(id = "imageMapEntry", name = "Image ID", value = {
@Selector(type = @Type(name = "ImageMapEntry"))
Expand All @@ -15,6 +18,18 @@ public class ImageMapEntryValueHandler extends ObjectValueHandler {
@NotNull
@Override
public Decorator getDecorator(@NotNull RTTIType<?> type) {
return (value, component) -> component.append(((RTTIObject) value).str("ID"), TextAttributes.REGULAR_ATTRIBUTES);
return (value, component) -> component.append("\"%s\"".formatted(getText(type, value)), CommonTextAttributes.STRING_TEXT_ATTRIBUTES);
}

@NotNull
@Override
public String getText(@NotNull RTTIType<?> type, @NotNull Object value) {
return ((RTTIObject) value).str("ID");
}

@Nullable
@Override
public Icon getIcon(@NotNull RTTIType<?> type) {
return UIManager.getIcon("Node.textureIcon");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.shade.decima.ui.data.handlers;

import com.shade.decima.model.rtti.RTTIType;
import com.shade.decima.model.rtti.objects.RTTIObject;
import com.shade.decima.ui.data.registry.ValueHandlerRegistration;
import com.shade.decima.ui.data.registry.ValueHandlerRegistration.Selector;
import com.shade.decima.ui.data.registry.ValueHandlerRegistration.Type;
import com.shade.util.NotNull;
import com.shade.util.Nullable;

import javax.swing.*;

@ValueHandlerRegistration(id = "meshPart", name = "Mesh part", value = {
@Selector(type = @Type(name = "MultiMeshResourcePart")),
@Selector(type = @Type(name = "LodMeshResourcePart"))
})
public class MeshResourcePartHandler extends ObjectValueHandler {
@Nullable
@Override
public Decorator getDecorator(@NotNull RTTIType<?> type) {
return (value, component) -> {
final RTTIObject obj = (RTTIObject) value;
ReferenceValueHandler.INSTANCE.getDecorator(type).decorate(obj.get("Mesh"), component);
};
}

@Nullable
@Override
public Icon getIcon(@NotNull RTTIType<?> type) {
return UIManager.getIcon("Node.modelIcon");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@

@ValueHandlerRegistration(id = "model", name = "Model", value = {
@Selector(type = @Type(name = "ModelResource")),
@Selector(type = @Type(name = "MeshResourceBase")),
@Selector(type = @Type(name = "MeshResourceBase"))
})
public class ModelValueHandler extends ObjectValueHandler {
@NotNull
@Override
public Decorator getDecorator(@NotNull RTTIType<?> type) {
return (value, component) -> ObjectWithNameValueHandler.INSTANCE.getDecorator(type).decorate(value, component);
}

@Nullable
@Override
public Icon getIcon(@NotNull RTTIType<?> type) {
Expand Down
Loading

0 comments on commit 9b0fc57

Please sign in to comment.