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

[FEATURE SUGGESTION] Custom blockname tint #1058

Open
TheEmbracedOne opened this issue Jun 27, 2022 · 0 comments
Open

[FEATURE SUGGESTION] Custom blockname tint #1058

TheEmbracedOne opened this issue Jun 27, 2022 · 0 comments

Comments

@TheEmbracedOne
Copy link

TheEmbracedOne commented Jun 27, 2022

It'd be neat if users could choose to colour blocknames on nodes the exact same way as custom tint but for colouring the name of the block:
Unity_hzHQ9mrrSr

Is your feature request related to a problem? Please describe.
Since you're able to set block colour, I think it makes sense to be able to have full control over the colour of the blockname as well. The code that colours text white or black based on brightness is a little unreliable, Color.magenta for example doesnt get coloured black, and with white text it's quite hard to read, here I'd suggest replacing the following:

//replace this:
nodeStyle.normal.textColor = brightness >= 0.5 ? Color.black : Color.white;

//with this:
Color.RGBToHSV(graphics.tint, out _, out _, out float value);
nodeStyle.normal.textColor = value>= 0.45 ? Color.black : Color.white;

I also have a bunch of custom error checking features I added to Fungus on my end that checks for broken/missing references, null characters/targetblocks and so on, which modifies the custom tint colour of blocks in which it found problems, and being able to colour text too is really useful for me.

Describe the solution you'd like
Normally I'd make a PR for this as I have written the functionality I desire, but I'm very pressed for time. I'll leave my notes and code here for either myself in the future or someone else to make a proper PR later:

Node.cs added:

[SerializeField] protected Color textTint = Color.white;
[SerializeField] protected bool useCustomTextColor;

public virtual bool UseCustomTextColor { get { return useCustomTextColor; } set { useCustomTextColor = value; } }
public virtual Color TextTint { get { return textTint; } set { textTint = value; } }

BlockEditor.cs:

SerializedProperty useCustomTextColorProp;
SerializedProperty textTintProp;

//----------------------------
//in DrawBlockGUI under the "EditorGUILayout.EndHorizontal();" below Custom Tint:
useCustomTextColorProp = serializedObject.FindProperty("useCustomTextColor");
textTintProp = serializedObject.FindProperty("textTint");

EditorGUILayout.BeginHorizontal();
useCustomTextColorProp.boolValue = GUILayout.Toggle(useCustomTextColorProp.boolValue, " Custom Text Tint");
if (useCustomTextColorProp.boolValue) {
	EditorGUILayout.PropertyField(textTintProp, GUIContent.none);
}
EditorGUILayout.EndHorizontal();

FlowchartWindow.cs:
add "textColor" to BLockGraphics:

protected struct BlockGraphics {
	internal Color tint;
	internal Color textColor;
	internal Texture2D onTexture;
	internal Texture2D offTexture;
}

Then insert between graphics.tint = (block.UseCustomTint ? block.Tint : defaultTint) * FungusEditorPreferences.flowchartBlockTint; and return graphics; inside GetBlockGraphics(Block block):

float value;
Color.RGBToHSV(graphics.tint, out _, out _, out value);
Color defaultTextTint = value >= 0.45 ? Color.black : Color.white;

graphics.textColor = (block.UseCustomTextColor ? block.TextTint : defaultTextTint);

//if locked, grey blocks (makes it easier to notice the flowchart's locked
if (flowchart.locked) { graphics.tint.a = 0.75f; }

FungusConstants.cs:

public static Color DefaultChoiceBlockTextTint = new Color(1.00f, 1.00f, 1.000f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant