Skip to content

Commit

Permalink
8.0.425
Browse files Browse the repository at this point in the history
  • Loading branch information
poiyomi committed Jul 29, 2022
1 parent 57093de commit 54414b7
Show file tree
Hide file tree
Showing 94 changed files with 6,170 additions and 862 deletions.
6 changes: 6 additions & 0 deletions _PoiyomiShaders/Scripts/ThryEditor/CREDITS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Shader Optimizer : Kaj (https://github.com/DarthShader)
sRGBWarningDrawer : z3y (https://github.com/z3y)
Auto Anchor Feature : Pumkin (https://github.com/rurre)

Shader Optimizer - Property Renaming : RequiDev (https://github.com/RequiDev)
Shader Optimizer - Shared Locked Shaders : 3 (https://github.com/Float3)
7 changes: 7 additions & 0 deletions _PoiyomiShaders/Scripts/ThryEditor/CREDITS.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.26.5";
private const string VERSION = "2.27.6";

// static
private static Config config;
Expand Down
77 changes: 63 additions & 14 deletions _PoiyomiShaders/Scripts/ThryEditor/Editor/DataStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ public class PATH

public class URL
{
public const string MODULE_COLLECTION = "https://thryeditor.thryrallo.de/files/modules.json";
public const string SETTINGS_MESSAGE_URL = "http://thryeditor.thryrallo.de/message.json";

public const string DATA_SHARE_SEND = "http://thryeditor.thryrallo.de/send_analytics.php";
public const string DATA_SHARE_GET_MY_DATA = "https://thryeditor.thryrallo.de/get_my_data.php";
public const string MODULE_COLLECTION = "https://raw.githubusercontent.com/Thryrallo/ThryEditorStreamedResources/main/modules.json";
public const string SETTINGS_MESSAGE_URL = "https://raw.githubusercontent.com/Thryrallo/ThryEditorStreamedResources/main/Messages/settingsWindow.json";
public const string COUNT_PROJECT = "http://thryeditor.thryrallo.de/count_project.php";
public const string COUNT_USER = "http://thryeditor.thryrallo.de/count_user.php";
}
Expand Down Expand Up @@ -67,7 +64,9 @@ public class DrawingData
public static bool LastPropertyDoesntAllowAnimation;
public static DrawerType LastPropertyDrawerType;
public static MaterialPropertyDrawer LastPropertyDrawer;
public static List<MaterialPropertyDrawer> LastPropertyDecorators = new List<MaterialPropertyDrawer>();
public static bool IsEnabled = true;
public static bool IsCollectingProperties = false;

public static ShaderPart LastInitiatedPart;

Expand All @@ -77,6 +76,15 @@ public static void ResetLastDrawerData()
LastPropertyDoesntAllowAnimation = false;
LastPropertyDrawer = null;
LastPropertyDrawerType = DrawerType.None;
LastPropertyDecorators.Clear();
}

public static void RegisterDecorator(MaterialPropertyDrawer drawer)
{
if(IsCollectingProperties)
{
LastPropertyDecorators.Add(drawer);
}
}
}

Expand Down Expand Up @@ -129,13 +137,13 @@ public class ButtonData
public TextureData texture = null;
public DefineableAction action = new DefineableAction();
public string hover = "";
public bool center_position = false;
public DefineableCondition condition_show = new DefineableCondition();
}

public class TextureData
{
public string name = null;

public int width = 128;
public int height = 128;

Expand All @@ -144,6 +152,8 @@ public class TextureData
public int ansioLevel = 1;
public FilterMode filterMode = FilterMode.Bilinear;
public TextureWrapMode wrapMode = TextureWrapMode.Repeat;
public bool center_position = false;
bool _isLoading;

public void ApplyModes(Texture texture)
{
Expand All @@ -160,21 +170,58 @@ public void ApplyModes(string path)
importer.SaveAndReimport();
}

private Texture p_loaded_texture;
static Dictionary<string, Texture> s_loaded_textures = new Dictionary<string, Texture>();
public Texture loaded_texture
{
get
{
if (p_loaded_texture == null)
if(!s_loaded_textures.ContainsKey(name) || s_loaded_textures[name] == null)
{
string path = FileHelper.FindFile(name, "texture");
if (path != null)
p_loaded_texture = AssetDatabase.LoadAssetAtPath<Texture>(path);
else
p_loaded_texture = new Texture2D(1, 1);
if(IsUrl())
{
if(!_isLoading)
{
WebHelper.DownloadBytesASync(name, (byte[] b) =>
{
_isLoading = false;
Texture2D tex = new Texture2D(1,1, TextureFormat.ARGB32, false);
ImageConversion.LoadImage(tex, b, false);
s_loaded_textures[name] = tex;
});
_isLoading = true;
}
}else
{
string path = FileHelper.FindFile(name, "texture");
if (path != null)
s_loaded_textures[name] = AssetDatabase.LoadAssetAtPath<Texture>(path);
else
s_loaded_textures[name] = new Texture2D(1, 1);
}
if(!s_loaded_textures.ContainsKey(name))
{
return null;
}
}
return p_loaded_texture;
return s_loaded_textures[name];
}
}

private static TextureData ParseForThryParser(string s)
{
if(s.StartsWith("{") == false)
{
return new TextureData()
{
name = s
};
}
return Parser.ParseToObject<TextureData>(s);
}

bool IsUrl()
{
return name.StartsWith("http") && (name.EndsWith(".jpg") || name.EndsWith(".png"));
}
}

Expand Down Expand Up @@ -206,6 +253,7 @@ private static PropertyValueAction ParseForThryParser(string s)
{
return Parse(s);
}

// value,property1=value1,property2=value2
public static PropertyValueAction Parse(string s)
{
Expand All @@ -230,6 +278,7 @@ private static PropertyValueAction[] ParseToArrayForThryParser(string s)
{
return ParseToArray(s);
}

public static PropertyValueAction[] ParseToArray(string s)
{
//s = v,p1=v1,p2=v2;v3
Expand Down
85 changes: 75 additions & 10 deletions _PoiyomiShaders/Scripts/ThryEditor/Editor/Drawers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void Init()
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
Init();
Rect border_position = new Rect(position.x + EditorGUIUtility.labelWidth - 15, position.y, position.width - EditorGUIUtility.labelWidth - position.x + 15, position.height);
Rect border_position = new Rect(position.x + EditorGUIUtility.labelWidth - 15, position.y, position.width - EditorGUIUtility.labelWidth + 15 - GuiHelper.GetSmallTextureVRAMWidth(prop), position.height);

EditorGUI.BeginChangeCheck();
curve = EditorGUI.CurveField(border_position, curve);
Expand Down Expand Up @@ -608,7 +608,7 @@ public override void OnGUI(Rect position, MaterialProperty prop, GUIContent labe
if (EditorGUI.EndChangeCheck())
Init(prop);

UpdateRects(position);
UpdateRects(position, prop);
if (ShaderEditor.Input.Click && border_position.Contains(Event.current.mousePosition))
{
ShaderEditor.Input.Use();
Expand All @@ -621,9 +621,9 @@ public override void OnGUI(Rect position, MaterialProperty prop, GUIContent labe
GradientField();
}

private void UpdateRects(Rect position)
private void UpdateRects(Rect position, MaterialProperty prop)
{
border_position = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, position.width - EditorGUIUtility.labelWidth - position.x, position.height);
border_position = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, position.width - EditorGUIUtility.labelWidth - GuiHelper.GetSmallTextureVRAMWidth(prop), position.height);
gradient_position = new Rect(border_position.x + 1, border_position.y + 1, border_position.width - 2, border_position.height - 2);
}

Expand Down Expand Up @@ -758,6 +758,7 @@ public ThryHeaderLabelDecorator(string text, float size)

public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
DrawingData.RegisterDecorator(this);
return size + 6;
}

Expand Down Expand Up @@ -1213,18 +1214,82 @@ public override float GetPropertyHeight(MaterialProperty prop, string label, Mat
}
}

public class sRGBWarningDrawer : MaterialPropertyDrawer
public class sRGBWarningDecorator : MaterialPropertyDrawer
{
bool _isSRGB = true;

public sRGBWarningDecorator()
{
_isSRGB = false;
}

public sRGBWarningDecorator(string shouldHaveSRGB)
{
this._isSRGB = shouldHaveSRGB.ToLower() == "true";
}

public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
GuiHelper.ColorspaceWarning(prop, _isSRGB);
}

public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
DrawingData.RegisterDecorator(this);
return 0;
}
}

public class LocalMessageDrawer : MaterialPropertyDrawer
{
protected ButtonData _buttonData;
protected bool _isInit;
protected virtual void Init(string s)
{
if(_isInit) return;
_buttonData = Parser.ParseToObject<ButtonData>(s);
_isInit = true;
}

public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
GuiHelper.ConfigTextureProperty(position, prop, label, editor, ((TextureProperty)ShaderEditor.Active.CurrentProperty).hasScaleOffset);
GuiHelper.sRGBWarning(prop);
Init(prop.displayName);
if(_buttonData == null) return;
if(_buttonData.text.Length > 0)
{
GUILayout.Label(new GUIContent(_buttonData.text,_buttonData.hover), _buttonData.center_position?Styles.richtext_center: Styles.richtext);
Rect r = GUILayoutUtility.GetLastRect();
if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
_buttonData.action.Perform(ShaderEditor.Active?.Materials);
}
if(_buttonData.texture != null)
{
if(_buttonData.center_position) GUILayout.Label(new GUIContent(_buttonData.texture.loaded_texture, _buttonData.hover), EditorStyles.centeredGreyMiniLabel, GUILayout.MaxHeight(_buttonData.texture.height));
else GUILayout.Label(new GUIContent(_buttonData.texture.loaded_texture, _buttonData.hover), GUILayout.MaxHeight(_buttonData.texture.height));
Rect r = GUILayoutUtility.GetLastRect();
if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
_buttonData.action.Perform(ShaderEditor.Active?.Materials);
}
}

public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
DrawingData.LastPropertyUsedCustomDrawer = true;
return base.GetPropertyHeight(prop, label, editor);
return 0;
}
}

public class RemoteMessageDrawer : LocalMessageDrawer
{

protected override void Init(string s)
{
if(_isInit) return;
WebHelper.DownloadStringASync(s, (string data) =>
{
_buttonData = Parser.ParseToObject<ButtonData>(data);
});
_isInit = true;
}
}

Expand Down Expand Up @@ -1302,8 +1367,8 @@ public override void OnGUI(Rect position, MaterialProperty shaderOptimizer, stri
{
Material material = shaderOptimizer.targets[0] as Material;
Shader shader = material.shader;
bool isLocked = shader.name.StartsWith("Hidden/") &&
(material.GetTag("OriginalShader",false,"") != "" || shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(shaderOptimizer.name)) == 1);
bool isLocked = shader.name.StartsWith("Hidden/Locked/") || (shader.name.StartsWith("Hidden/") &&
(material.GetTag("OriginalShader",false,"") != "" && shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(shaderOptimizer.name)) == 1));
//this will make sure the button is unlocked if you manually swap to an unlocked shader
//shaders that have the ability to be locked shouldnt really be hidden themself. at least it wouldnt make too much sense
if (shaderOptimizer.hasMixedValue == false && shaderOptimizer.floatValue == 1 && isLocked == false)
Expand Down
Loading

0 comments on commit 54414b7

Please sign in to comment.