Skip to content

Commit

Permalink
8.0.420
Browse files Browse the repository at this point in the history
Final version of 8.0 I hope
  • Loading branch information
poiyomi committed Jul 13, 2022
1 parent a56a275 commit 531d946
Show file tree
Hide file tree
Showing 282 changed files with 9,335 additions and 27,079 deletions.
2 changes: 1 addition & 1 deletion _PoiyomiShaders/Scripts/ThryEditor/Editor/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Config
{
// consts
private const string PATH_CONFIG_FILE = "Thry/Config.json";
private const string VERSION = "2.25.7";
private const string VERSION = "2.26.5";

// static
private static Config config;
Expand Down
133 changes: 81 additions & 52 deletions _PoiyomiShaders/Scripts/ThryEditor/Editor/DataStructs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Material/Shader Inspector for Unity 2017/2018
// Copyright (C) 2019 Thryrallo

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -300,17 +301,17 @@ public static DefineableAction Parse(string s)
{
s = s.Trim();
DefineableAction action = new DefineableAction();
if (s.StartsWith("http") || s.StartsWith("www"))
if (s.StartsWith("http", StringComparison.Ordinal) || s.StartsWith("www", StringComparison.Ordinal))
{
action.type = DefineableActionType.URL;
action.data = s;
}
else if (s.StartsWith("tag::"))
else if (s.StartsWith("tag::", StringComparison.Ordinal))
{
action.type = DefineableActionType.SET_TAG;
action.data = s.Replace("tag::", "");
}
else if (s.StartsWith("shader="))
else if (s.StartsWith("shader=", StringComparison.Ordinal))
{
action.type = DefineableActionType.SET_SHADER;
action.data = s.Replace("shader=", "");
Expand All @@ -332,7 +333,7 @@ public static DefineableAction ParseDrawerParameter(string s)
{
s = s.Trim();
DefineableAction action = new DefineableAction();
if (s.StartsWith("youtube#"))
if (s.StartsWith("youtube#", StringComparison.Ordinal))
{
action.type = DefineableActionType.URL;
action.data = "https://www.youtube.com/watch?v="+s.Substring(8);
Expand Down Expand Up @@ -366,6 +367,7 @@ public class DefineableCondition
CompareType _compareType;
string _obj;
ShaderProperty _propertyObj;
Material _materialInsteadOfEditor;

string _value;
float _floatValue;
Expand Down Expand Up @@ -434,27 +436,35 @@ public bool Test()
Init();
if (_hasConstantValue) return _constantValue;

MaterialProperty materialProperty = null;
switch (type)
{
case DefineableConditionType.PROPERTY_BOOL:
if (_propertyObj == null) return false;
if (_compareType == CompareType.NONE) return _propertyObj.MaterialProperty.floatValue == 1;
if (_compareType == CompareType.EQUAL) return _propertyObj.MaterialProperty.floatValue == _floatValue;
if (_compareType == CompareType.NOT_EQUAL) return _propertyObj.MaterialProperty.floatValue != _floatValue;
if (_compareType == CompareType.SMALLER) return _propertyObj.MaterialProperty.floatValue < _floatValue;
if (_compareType == CompareType.BIGGER) return _propertyObj.MaterialProperty.floatValue > _floatValue;
if (_compareType == CompareType.BIGGER_EQ) return _propertyObj.MaterialProperty.floatValue >= _floatValue;
if (_compareType == CompareType.SMALLER_EQ) return _propertyObj.MaterialProperty.floatValue <= _floatValue;
materialProperty = GetMaterialProperty();
if (materialProperty == null) return false;
if (_compareType == CompareType.NONE) return materialProperty.floatValue == 1;
if (_compareType == CompareType.EQUAL) return materialProperty.floatValue == _floatValue;
if (_compareType == CompareType.NOT_EQUAL) return materialProperty.floatValue != _floatValue;
if (_compareType == CompareType.SMALLER) return materialProperty.floatValue < _floatValue;
if (_compareType == CompareType.BIGGER) return materialProperty.floatValue > _floatValue;
if (_compareType == CompareType.BIGGER_EQ) return materialProperty.floatValue >= _floatValue;
if (_compareType == CompareType.SMALLER_EQ) return materialProperty.floatValue <= _floatValue;
break;
case DefineableConditionType.TEXTURE_SET:
if (_propertyObj == null) return false;
return _propertyObj.MaterialProperty.textureValue != null;
materialProperty = GetMaterialProperty();
if (materialProperty == null) return false;
return materialProperty.textureValue != null;
case DefineableConditionType.DROPDOWN:
if (_propertyObj == null) return false;
if (_compareType == CompareType.NONE) return _propertyObj.MaterialProperty.floatValue == 1;
if (_compareType == CompareType.EQUAL) return "" + _propertyObj.MaterialProperty.floatValue == _value;
if (_compareType == CompareType.NOT_EQUAL) return "" + _propertyObj.MaterialProperty.floatValue != _value;
materialProperty = GetMaterialProperty();
if (materialProperty == null) return false;
if (_compareType == CompareType.NONE) return materialProperty.floatValue == 1;
if (_compareType == CompareType.EQUAL) return "" + materialProperty.floatValue == _value;
if (_compareType == CompareType.NOT_EQUAL) return "" + materialProperty.floatValue != _value;
break;
case DefineableConditionType.PROPERTY_IS_ANIMATED:
return ShaderOptimizer.IsAnimated(_materialInsteadOfEditor, _obj);
case DefineableConditionType.PROPERTY_IS_NOT_ANIMATED:
return !ShaderOptimizer.IsAnimated(_materialInsteadOfEditor, _obj);
case DefineableConditionType.AND:
if(condition1!=null&&condition2!=null) return condition1.Test() && condition2.Test();
break;
Expand All @@ -465,6 +475,13 @@ public bool Test()

return true;
}

private MaterialProperty GetMaterialProperty()
{
if(_materialInsteadOfEditor) return MaterialEditor.GetMaterialProperty(new Material[]{_materialInsteadOfEditor}, _obj);
if(_propertyObj != null) return _propertyObj.MaterialProperty;
return null;
}
private (CompareType,string) GetComparetor()
{
if (data.Contains("=="))
Expand Down Expand Up @@ -492,6 +509,14 @@ public override string ToString()
return "EDITOR_VERSION" + data;
case DefineableConditionType.VRC_SDK_VERSION:
return "VRC_SDK_VERSION" + data;
case DefineableConditionType.TEXTURE_SET:
return "TEXTURE_SET" + data;
case DefineableConditionType.DROPDOWN:
return "DROPDOWN" + data;
case DefineableConditionType.PROPERTY_IS_ANIMATED:
return $"isAnimated({data})";
case DefineableConditionType.PROPERTY_IS_NOT_ANIMATED:
return $"isNotAnimated({data})";
case DefineableConditionType.AND:
if (condition1 != null && condition2 != null) return "("+condition1.ToString() + "&&" + condition2.ToString()+")";
break;
Expand All @@ -506,8 +531,13 @@ private static DefineableCondition ParseForThryParser(string s)
{
return Parse(s);
}
public static DefineableCondition Parse(string s)

private static readonly char[] ComparissionLiteralsToCheckFor = "*><=".ToCharArray();
public static DefineableCondition Parse(string s, Material useThisMaterialInsteadOfOpenEditor = null)
{
DefineableCondition con = new DefineableCondition();
con._materialInsteadOfEditor = useThisMaterialInsteadOfOpenEditor;

s = Strip(s);

int depth = 0;
Expand All @@ -524,58 +554,55 @@ public static DefineableCondition Parse(string s)
{
if (c == '&' && cc == '&')
{
DefineableCondition con = new DefineableCondition();
con.type = DefineableConditionType.AND;
con.condition1 = Parse(s.Substring(0, i));
con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2));
con.condition1 = Parse(s.Substring(0, i), useThisMaterialInsteadOfOpenEditor);
con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2), useThisMaterialInsteadOfOpenEditor);
return con;
}
if (c == '|' && cc == '|')
{
DefineableCondition con = new DefineableCondition();
con.type = DefineableConditionType.OR;
con.condition1 = Parse(s.Substring(0, i));
con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2));
con.condition1 = Parse(s.Substring(0, i), useThisMaterialInsteadOfOpenEditor);
con.condition2 = Parse(s.Substring(i + 2, s.Length - i - 2), useThisMaterialInsteadOfOpenEditor);
return con;
}
}
}
for (int i = 0; i < s.Length - 1; i++)
if(s.IndexOfAny(ComparissionLiteralsToCheckFor) != -1)
{
char c = s[i];
char cc = s[i + 1];
if (c == '(')
depth++;
else if (c == ')')
depth--;

if (depth == 0)
//is a comparission
con.data = s;
con.type = DefineableConditionType.PROPERTY_BOOL;
if (s.StartsWith("VRCSDK", StringComparison.Ordinal))
{
if (c == '>' || c=='<' || c=='=' || c == '!')
{
DefineableCondition con = new DefineableCondition();
con.data = s;
con.type = DefineableConditionType.PROPERTY_BOOL;
if (s.StartsWith("VRCSDK"))
{
con.type = DefineableConditionType.VRC_SDK_VERSION;
con.data = s.Replace("VRCSDK", "");
}else if (s.StartsWith("ThryEditor"))
{
con.type = DefineableConditionType.VRC_SDK_VERSION;
con.data = s.Replace("ThryEditor", "");
}
return con;
}
con.type = DefineableConditionType.VRC_SDK_VERSION;
con.data = s.Replace("VRCSDK", "");
}else if (s.StartsWith("ThryEditor", StringComparison.Ordinal))
{
con.type = DefineableConditionType.EDITOR_VERSION;
con.data = s.Replace("ThryEditor", "");
}
return con;
}
if(s.StartsWith("isNotAnimated(", StringComparison.Ordinal))
{
con.type = DefineableConditionType.PROPERTY_IS_NOT_ANIMATED;
con.data = s.Replace("isNotAnimated(", "").TrimEnd(')');
return con;
}
if(s.StartsWith("isAnimated(", StringComparison.Ordinal))
{
con.type = DefineableConditionType.PROPERTY_IS_ANIMATED;
con.data = s.Replace("isAnimated(", "").TrimEnd(')');
return con;
}
return new DefineableCondition();
return con;
}

private static string Strip(string s)
{
s = s.Trim();
if (s.StartsWith("(") == false)
if (s.StartsWith("(", StringComparison.Ordinal) == false)
return s;
bool stripKlammer = true;
int depth = 0;
Expand Down Expand Up @@ -604,6 +631,8 @@ public enum DefineableConditionType
TRUE,
FALSE,
PROPERTY_BOOL,
PROPERTY_IS_ANIMATED,
PROPERTY_IS_NOT_ANIMATED,
EDITOR_VERSION,
VRC_SDK_VERSION,
TEXTURE_SET,
Expand Down
23 changes: 20 additions & 3 deletions _PoiyomiShaders/Scripts/ThryEditor/Editor/Drawers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,11 @@ public override float GetPropertyHeight(MaterialProperty prop, string label, Mat
{
return EditorGUIUtility.singleLineHeight * 2.5f;
}
if (hasKeyword) CheckKeyword(prop);
if (hasKeyword)
{
CheckKeyword(prop);
DrawingData.LastPropertyDoesntAllowAnimation = true;
}
return base.GetPropertyHeight(prop, label, editor);
}

Expand Down Expand Up @@ -1076,6 +1080,7 @@ public override float GetPropertyHeight(MaterialProperty prop, string label, Mat
public class ThryMultiFloatsDrawer : MaterialPropertyDrawer
{
string[] _otherProperties;
MaterialProperty[] _otherMaterialProps;
bool _displayAsToggles;

public ThryMultiFloatsDrawer(string displayAsToggles, string p1, string p2, string p3, string p4, string p5, string p6, string p7) : this(displayAsToggles, new string[] { p1, p2, p3, p4, p5, p6, p7 }) { }
Expand All @@ -1090,6 +1095,7 @@ public ThryMultiFloatsDrawer(string displayAsToggles, params string[] extraPrope
{
_displayAsToggles = displayAsToggles.ToLower() == "true" || displayAsToggles == "1";
_otherProperties = extraProperties;
_otherMaterialProps = new MaterialProperty[extraProperties.Length];
}

public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
Expand All @@ -1100,14 +1106,25 @@ public override void OnGUI(Rect position, MaterialProperty prop, GUIContent labe
contentR.width = (contentR.width - labelR.width) / (_otherProperties.Length + 1);
contentR.x += labelR.width;

for (int i = 0; i < _otherProperties.Length; i++)
_otherMaterialProps[i] = ShaderEditor.Active.PropertyDictionary[_otherProperties[i]].MaterialProperty;
EditorGUI.BeginChangeCheck();

EditorGUI.LabelField(labelR, label);
int indentLevel = EditorGUI.indentLevel; //else it double indents
EditorGUI.indentLevel = 0;
PropGUI(prop, contentR, 0);
if(ShaderEditor.Active.IsInAnimationMode)
MaterialEditor.PrepareMaterialPropertiesForAnimationMode(_otherMaterialProps, true);
for (int i = 0; i < _otherProperties.Length; i++)
PropGUI(ShaderEditor.Active.PropertyDictionary[_otherProperties[i]].MaterialProperty, contentR, i + 1);
{
PropGUI(_otherMaterialProps[i], contentR, i + 1);
}
EditorGUI.indentLevel = indentLevel;


//If edited in animation mode mark as animated (needed cause other properties isnt checked in draw)
if(EditorGUI.EndChangeCheck() && ShaderEditor.Active.IsInAnimationMode && !ShaderEditor.Active.CurrentProperty.IsAnimated)
ShaderEditor.Active.CurrentProperty.SetAnimated(true, false);
//make sure all are animated together
bool animated = ShaderEditor.Active.CurrentProperty.IsAnimated;
bool renamed = ShaderEditor.Active.CurrentProperty.IsRenaming;
Expand Down
Loading

0 comments on commit 531d946

Please sign in to comment.