Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameHashValueHandler for resolving the binding hash to the shader resource binding name #70

Merged
merged 6 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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