Skip to content

Commit

Permalink
Fix Stuff again
Browse files Browse the repository at this point in the history
- Fixed Node Header Text Overflow
- Changed The Readme
- Added New Preview Images
- Changed Node Texture
- More Mod Settings
  • Loading branch information
DexyThePuppy committed Dec 10, 2024
1 parent 670a5e0 commit d450f67
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/References/FrooxEngine

Binary file modified ProtoFluxVisualsOverhaul/Images/Background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ProtoFluxVisualsOverhaul/Images/CloseUp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ProtoFluxVisualsOverhaul/Images/Node.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ProtoFluxVisualsOverhaul/Images/Nodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 40 additions & 17 deletions ProtoFluxVisualsOverhaul/ProtoFluxRoundedUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ public static bool HasPermission(ProtoFluxNodeVisual instance) {
// Patch to add rounded corners to ProtoFlux node visuals
[HarmonyPatch(typeof(ProtoFluxNodeVisual), "BuildUI")]
public class ProtoFluxNodeVisual_BuildUI_Patch {
private static readonly Uri ROUNDED_TEXTURE = new Uri("resdb:///3ee5c0335455c19970d877e2b80f7869539df43fccb8fc64b38e320fc44c154f.png");
private static readonly Uri CONNECTOR_INPUT_TEXTURE = new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector.png");
private static readonly Uri CONNECTOR_OUTPUT_TEXTURE = new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector.png");
private static readonly Uri CALL_CONNECTOR_OUTPUT_TEXTURE = new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector_Output.png");
private static readonly Uri CALL_CONNECTOR_INPUT_TEXTURE = new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector_Input.png");

// ColorMyProtoFlux color settings
private static readonly colorX NODE_CATEGORY_TEXT_LIGHT_COLOR = new colorX(0.75f);
private static readonly colorX NODE_CATEGORY_TEXT_DARK_COLOR = new colorX(0.25f);
Expand Down Expand Up @@ -140,7 +134,9 @@ public static SpriteProvider GetOrCreateSharedConnectorSprite(Slot slot, bool is
// Set up the texture if not already set
if (spriteProvider.Texture.Target == null) {
var texture = spriteProvider.Slot.AttachComponent<StaticTexture2D>();
texture.URL.Value = isOutput ? CONNECTOR_OUTPUT_TEXTURE : CONNECTOR_INPUT_TEXTURE;
texture.URL.Value = isOutput ?
ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.CONNECTOR_OUTPUT_TEXTURE) :
ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.CONNECTOR_INPUT_TEXTURE);
texture.FilterMode.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FILTER_MODE);
texture.WrapModeU.Value = TextureWrapMode.Clamp;
texture.WrapModeV.Value = TextureWrapMode.Clamp;
Expand All @@ -153,6 +149,8 @@ public static SpriteProvider GetOrCreateSharedConnectorSprite(Slot slot, bool is
texture.Uncompressed.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.UNCOMPRESSED);
texture.DirectLoad.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.DIRECT_LOAD);
texture.ForceExactVariant.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FORCE_EXACT_VARIANT);
texture.PreferredFormat.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_FORMAT);
texture.PreferredProfile.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_PROFILE);

spriteProvider.Texture.Target = texture;
spriteProvider.Rect.Value = !isOutput ?
Expand Down Expand Up @@ -192,7 +190,9 @@ public static SpriteProvider GetOrCreateSharedCallConnectorSprite(Slot slot, boo
// Set up the texture if not already set
if (spriteProvider.Texture.Target == null) {
var texture = spriteProvider.Slot.AttachComponent<StaticTexture2D>();
texture.URL.Value = isOutput ? CALL_CONNECTOR_OUTPUT_TEXTURE : CALL_CONNECTOR_INPUT_TEXTURE;
texture.URL.Value = isOutput ?
ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.CALL_CONNECTOR_OUTPUT_TEXTURE) :
ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.CALL_CONNECTOR_INPUT_TEXTURE);
texture.FilterMode.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FILTER_MODE);
texture.WrapModeU.Value = TextureWrapMode.Clamp;
texture.WrapModeV.Value = TextureWrapMode.Clamp;
Expand All @@ -205,6 +205,8 @@ public static SpriteProvider GetOrCreateSharedCallConnectorSprite(Slot slot, boo
texture.Uncompressed.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.UNCOMPRESSED);
texture.DirectLoad.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.DIRECT_LOAD);
texture.ForceExactVariant.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FORCE_EXACT_VARIANT);
texture.PreferredFormat.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_FORMAT);
texture.PreferredProfile.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_PROFILE);

spriteProvider.Texture.Target = texture;
spriteProvider.Rect.Value = !isOutput ?
Expand Down Expand Up @@ -304,10 +306,10 @@ public static void Postfix(ProtoFluxNodeVisual __instance, UIBuilder ui, ProtoFl

// Add overlapping layout to parent with exact settings
var overlappingLayout = titleParentSlot.AttachComponent<OverlappingLayout>();
overlappingLayout.PaddingTop.Value = 4f;
overlappingLayout.PaddingRight.Value = 4f;
overlappingLayout.PaddingBottom.Value = 4f;
overlappingLayout.PaddingLeft.Value = 4f;
overlappingLayout.PaddingTop.Value = 5.5f;
overlappingLayout.PaddingRight.Value = 5.5f;
overlappingLayout.PaddingBottom.Value = 2.5f;
overlappingLayout.PaddingLeft.Value = 5.5f;
overlappingLayout.HorizontalAlign.Value = LayoutHorizontalAlignment.Center;
overlappingLayout.VerticalAlign.Value = LayoutVerticalAlignment.Middle;
overlappingLayout.ForceExpandWidth.Value = true;
Expand Down Expand Up @@ -340,7 +342,12 @@ public static void Postfix(ProtoFluxNodeVisual __instance, UIBuilder ui, ProtoFl
var newTextSlot = newHeaderSlot.AddSlot("Text");
newTextSlot.ActiveSelf = true;
var newText = newTextSlot.AttachComponent<Text>();
var textRect = newText.RectTransform;

// Set the anchors to stretch horizontally and vertically
textRect.AnchorMin.Value = new float2(0.028f, 0.098f); // x:0.028 y:0.098
textRect.AnchorMax.Value = new float2(0.97f, 0.9f); // x:0.97 y:0.9

// Apply text settings
newText.Size.Value = 64.00f;
newText.HorizontalAlign.Value = TextHorizontalAlignment.Center;
Expand All @@ -366,6 +373,8 @@ public static void Postfix(ProtoFluxNodeVisual __instance, UIBuilder ui, ProtoFl
// Set text color multiple ways to ensure it takes effect
newText.Color.Value = textColor;
newText.Color.ForceSet(textColor);
newText.Size.Value = 9.00f;
newText.AutoSizeMin.Value = 4f;

// Convert color to hex based on brightness
newText.Content.Value = $"<color={(brightness > 0.6f ? "#000000" : "#FFFFFF")}><b>{headerText.Content.Value}</b></color>";
Expand All @@ -391,6 +400,17 @@ public static void Postfix(ProtoFluxNodeVisual __instance, UIBuilder ui, ProtoFl

ProtoFluxVisualsOverhaul.Msg("✅ Successfully reorganized title layout!");
}

// Find the category text (it's the last Text component with dark gray color)
var categoryText = ui.Root.GetComponentsInChildren<Text>()
.LastOrDefault(text => text.Color.Value == colorX.DarkGray);

if (categoryText != null) {
categoryText.VerticalAlign.Value = TextVerticalAlignment.Middle;
categoryText.Size.Value = 8.00f;
categoryText.AlignmentMode.Value = AlignmentMode.LineBased;
categoryText.LineHeight.Value = 0.35f;
}
}
catch (System.Exception e) {
ProtoFluxVisualsOverhaul.Msg($"❌ Error in ProtoFluxNodeVisual_BuildUI_Patch: {e.Message}");
Expand All @@ -409,7 +429,7 @@ private static void ApplyRoundedCorners(Image image) {

// Set up the texture
var texture = spriteProvider.Slot.AttachComponent<StaticTexture2D>();
texture.URL.Value = ROUNDED_TEXTURE;
texture.URL.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.NODE_BACKGROUND_HEADER_TEXTURE);
texture.FilterMode.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FILTER_MODE);
texture.WrapModeU.Value = TextureWrapMode.Clamp;
texture.WrapModeV.Value = TextureWrapMode.Clamp;
Expand All @@ -422,13 +442,15 @@ private static void ApplyRoundedCorners(Image image) {
texture.Uncompressed.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.UNCOMPRESSED);
texture.DirectLoad.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.DIRECT_LOAD);
texture.ForceExactVariant.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FORCE_EXACT_VARIANT);
texture.PreferredFormat.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_FORMAT);
texture.PreferredProfile.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_PROFILE);
ProtoFluxVisualsOverhaul.Msg("✅ Set up texture for header");

// Configure the sprite provider based on the image settings
spriteProvider.Texture.Target = texture;
spriteProvider.Rect.Value = new Elements.Core.Rect(0f, 0f, 1f, 1f); // x:0 y:0 width:1 height:1
spriteProvider.Borders.Value = new float4(0.5f, 0.5f, 0.5f, 0.5f);
spriteProvider.Scale.Value = 0.02f; // Scale: 0.05
spriteProvider.Scale.Value = 0.03f; // Scale: 0.05
spriteProvider.FixedSize.Value = 1.00f; // FixedSize: 1.00
ProtoFluxVisualsOverhaul.Msg("✅ Configured header sprite provider settings");

Expand Down Expand Up @@ -555,7 +577,6 @@ public static void Postfix(ProtoFluxNodeVisual __instance) {
// Keep the OnChanges patch for the background image
[HarmonyPatch(typeof(ProtoFluxNodeVisual), "OnChanges")]
public class ProtoFluxNodeVisual_OnChanges_Patch {
private static readonly Uri ROUNDED_TEXTURE = new Uri("resdb:///3ee5c0335455c19970d877e2b80f7869539df43fccb8fc64b38e320fc44c154f.png");
private static readonly FieldInfo bgImageField = AccessTools.Field(typeof(ProtoFluxNodeVisual), "_bgImage");

public static void Postfix(ProtoFluxNodeVisual __instance) {
Expand Down Expand Up @@ -590,7 +611,7 @@ private static void ApplyRoundedCorners(Image image) {

// Set up the texture
var texture = spriteProvider.Slot.AttachComponent<StaticTexture2D>();
texture.URL.Value = ROUNDED_TEXTURE;
texture.URL.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.NODE_BACKGROUND_TEXTURE);
texture.FilterMode.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FILTER_MODE);
texture.WrapModeU.Value = TextureWrapMode.Clamp;
texture.WrapModeV.Value = TextureWrapMode.Clamp;
Expand All @@ -603,14 +624,16 @@ private static void ApplyRoundedCorners(Image image) {
texture.Uncompressed.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.UNCOMPRESSED);
texture.DirectLoad.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.DIRECT_LOAD);
texture.ForceExactVariant.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.FORCE_EXACT_VARIANT);
texture.PreferredFormat.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_FORMAT);
texture.PreferredProfile.Value = ProtoFluxVisualsOverhaul.Config.GetValue(ProtoFluxVisualsOverhaul.PREFERRED_PROFILE);

ProtoFluxVisualsOverhaul.Msg("✅ Set up texture for background");

// Configure the sprite provider based on the image settings
spriteProvider.Texture.Target = texture;
spriteProvider.Rect.Value = new Elements.Core.Rect(0f, 0f, 1f, 1f); // x:0 y:0 width:1 height:1
spriteProvider.Borders.Value = new float4(0.5f, 0.5f, 0.5f, 0.5f); // x:0.5 y:0 z:0 w:0
spriteProvider.Scale.Value = 0.03f; // Scale: 0.05
spriteProvider.Scale.Value = 0.07f; // Scale: 0.05
spriteProvider.FixedSize.Value = 1.00f; // FixedSize: 1.00
ProtoFluxVisualsOverhaul.Msg("✅ Configured background sprite provider settings");

Expand Down
68 changes: 49 additions & 19 deletions ProtoFluxVisualsOverhaul/ProtoFluxVisualsOverhaul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ public class ProtoFluxVisualsOverhaul : ResoniteMod {
[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> NEAR_TEXTURE = new("nearTexture", "Near Texture URL", () => new Uri("resdb:///de2b9dfc4d029bd32ec784078b7511f0a8f18d2690595fc2540729da63a37f0a.webp"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> ROUNDED_TEXTURE = new("roundedTexture", "Rounded Texture URL", () => new Uri("resdb:///3ee5c0335455c19970d877e2b80f7869539df43fccb8fc64b38e320fc44c154f.png"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> CONNECTOR_INPUT_TEXTURE = new("connectorInputTexture", "Connector Input Texture URL", () => new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector.png"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> CONNECTOR_OUTPUT_TEXTURE = new("connectorOutputTexture", "Connector Output Texture URL", () => new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector.png"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> CALL_CONNECTOR_OUTPUT_TEXTURE = new("callConnectorOutputTexture", "Call Connector Output Texture URL", () => new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector_Output.png"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> CALL_CONNECTOR_INPUT_TEXTURE = new("callConnectorInputTexture", "Call Connector Input Texture URL", () => new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Connector_Input.png"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> NODE_BACKGROUND_TEXTURE = new("nodeBackgroundTexture", "Node Background Texture URL", () => new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Node_Background.png"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<Uri> NODE_BACKGROUND_HEADER_TEXTURE = new("nodeBackgroundHeaderTexture", "Node Background Header Texture URL", () => new Uri("https://raw.githubusercontent.com/DexyThePuppy/ProtoFluxVisualsOverhaul/refs/heads/main/ProtoFluxVisualsOverhaul/Images/Node_Header_Background.png"));

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<TextureFilterMode> FILTER_MODE = new("filterMode", "Texture Filter Mode", () => TextureFilterMode.Anisotropic);

Expand All @@ -52,7 +73,7 @@ public class ProtoFluxVisualsOverhaul : ResoniteMod {
public static readonly ModConfigurationKey<bool> DIRECT_LOAD = new("directLoad", "Direct Load", () => false);

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<bool> FORCE_EXACT_VARIANT = new("forceExactVariant", "Force Exact Variant", () => false);
public static readonly ModConfigurationKey<bool> FORCE_EXACT_VARIANT = new("forceExactVariant", "Force Exact Variant", () => true);

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<bool> CRUNCH_COMPRESSED = new("crunchCompressed", "Use Crunch Compression", () => true);
Expand All @@ -75,35 +96,44 @@ public class ProtoFluxVisualsOverhaul : ResoniteMod {
[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<int> ANISOTROPIC_LEVEL = new("anisotropicLevel", "Anisotropic Level", () => 8);

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<TextureCompression> PREFERRED_FORMAT = new("preferredFormat", "Preferred Texture Format", () => TextureCompression.BC3_Crunched);

[AutoRegisterConfigKey]
public static readonly ModConfigurationKey<ColorProfile> PREFERRED_PROFILE = new("preferredProfile", "Preferred Color Profile", () => ColorProfile.sRGB);


public override void OnEngineInit() {
Config = GetConfiguration();
Config.Save(true); // Save default config values
Config.Save(true);

Harmony harmony = new Harmony("com.Dexy.ProtoFluxVisualsOverhaul");
harmony.PatchAll();
Msg("🐾 ProtoFluxVisualsOverhaul successfully loaded and patched! Woof!");

Config.OnThisConfigurationChanged += (k) => {
if (k.Key != ENABLED) {
foreach (var kvp in pannerCache) {
var panner = kvp.Value;
if (panner == null) continue;

panner.Speed = Config.GetValue(SCROLL_SPEED);
panner.Repeat = Config.GetValue(SCROLL_REPEAT);
panner.PingPong.Value = Config.GetValue(PING_PONG);

// Get the FresnelMaterial
var fresnelMaterial = kvp.Key.GetComponent<FresnelMaterial>();
if (fresnelMaterial != null) {
var farTexture = GetOrCreateSharedTexture(fresnelMaterial.Slot, Config.GetValue(FAR_TEXTURE));
fresnelMaterial.FarTexture.Target = farTexture;

var nearTexture = GetOrCreateSharedTexture(fresnelMaterial.Slot, Config.GetValue(NEAR_TEXTURE));
fresnelMaterial.NearTexture.Target = nearTexture;
Engine.Current.GlobalCoroutineManager.StartTask(async () => {
await default(ToWorld);
foreach (var kvp in pannerCache) {
var panner = kvp.Value;
if (panner == null) continue;

panner.Speed = Config.GetValue(SCROLL_SPEED);
panner.Repeat = Config.GetValue(SCROLL_REPEAT);
panner.PingPong.Value = Config.GetValue(PING_PONG);

// Get the FresnelMaterial
var fresnelMaterial = kvp.Key.GetComponent<FresnelMaterial>();
if (fresnelMaterial != null) {
var farTexture = GetOrCreateSharedTexture(fresnelMaterial.Slot, Config.GetValue(FAR_TEXTURE));
fresnelMaterial.FarTexture.Target = farTexture;

var nearTexture = GetOrCreateSharedTexture(fresnelMaterial.Slot, Config.GetValue(NEAR_TEXTURE));
fresnelMaterial.NearTexture.Target = nearTexture;
}
}
}
});
}
};

Expand Down
Loading

0 comments on commit d450f67

Please sign in to comment.