Skip to content

Commit

Permalink
8.1.167
Browse files Browse the repository at this point in the history
  • Loading branch information
poiyomi committed Jul 26, 2023
1 parent 6d6a70e commit 2c7f7a0
Show file tree
Hide file tree
Showing 22 changed files with 1,277 additions and 868 deletions.
2 changes: 1 addition & 1 deletion _PoiyomiShaders/Scripts.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.42.1";
private const string VERSION = "2.43.3";

// static
private static Config config;
Expand Down
3 changes: 3 additions & 0 deletions _PoiyomiShaders/Scripts/ThryEditor/Editor/DataStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class DrawingData
public static Rect LastGuiObjectRect;
public static Rect LastGuiObjectHeaderRect;
public static Rect TooltipCheckRect;
public static float IconsPositioningHeight;
public static bool LastPropertyUsedCustomDrawer;
public static bool LastPropertyDoesntAllowAnimation;
public static DrawerType LastPropertyDrawerType;
Expand Down Expand Up @@ -108,6 +109,7 @@ public class PropertyOptions
public DefineableAction altClick;
public DefineableAction onClick;
public DefineableCondition condition_show = new DefineableCondition();
public DefineableCondition condition_expand = new DefineableCondition();
public string condition_showS;
public DefineableCondition condition_enable = null;
public PropertyValueAction[] on_value_actions;
Expand All @@ -124,6 +126,7 @@ public class PropertyOptions
public string generic_string;
public bool never_lock;
public bool draw_border;
public float margin_top = 0;

public static PropertyOptions Deserialize(string s)
{
Expand Down
22 changes: 21 additions & 1 deletion _PoiyomiShaders/Scripts/ThryEditor/Editor/Drawers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,26 @@ public override float GetPropertyHeight(MaterialProperty prop, string label, Mat

#endregion

#region Float Drawers
public class ThryIntRangeDrawer: MaterialPropertyDrawer
{
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
var range = prop.rangeLimits;
EditorGUI.BeginChangeCheck();
var value = EditorGUI.IntSlider(position, label, (int)prop.floatValue, (int)range.x, (int)range.y);
if (EditorGUI.EndChangeCheck())
prop.floatValue = value;
}

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

#region UI Drawers
public class HelpboxDrawer : MaterialPropertyDrawer
{
Expand Down Expand Up @@ -2017,7 +2037,7 @@ void ButtonSceneTools(Rect r)
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
DrawingData.LastPropertyUsedCustomDrawer = true;
DrawingData.LastPropertyDoesntAllowAnimation = true;
DrawingData.LastPropertyDoesntAllowAnimation = false;
return EditorGUIUtility.singleLineHeight + 6;
}
}
Expand Down
51 changes: 42 additions & 9 deletions _PoiyomiShaders/Scripts/ThryEditor/Editor/EditorStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ private void PerformDraw(GUIContent content, CRect rect, bool useEditorIndent, b
EditorGUI.BeginChangeCheck();
DrawInternal(content, rect, useEditorIndent, isInHeader);

if(this is TextureProperty == false) DrawingData.TooltipCheckRect = DrawingData.LastGuiObjectRect;
if(this is TextureProperty == false)
{
DrawingData.TooltipCheckRect = DrawingData.LastGuiObjectRect;
DrawingData.IconsPositioningHeight = DrawingData.LastGuiObjectRect.y + DrawingData.LastGuiObjectRect.height - 14;
}
DrawingData.TooltipCheckRect.width = EditorGUIUtility.labelWidth;

HandleRightClickToggles(isInHeader);
Expand Down Expand Up @@ -432,17 +436,17 @@ protected virtual void OnPropertyValueChanged()

private void DrawLockedAnimated()
{
Rect r = new Rect(14, DrawingData.TooltipCheckRect.y + 2, 16, 16);
Rect r = new Rect(14, DrawingData.IconsPositioningHeight, 16, 16);
//GUI.DrawTexture(r, is_renaming ? Styles.texture_animated_renamed : Styles.texture_animated, ScaleMode.StretchToFill, true);
if (IsRenaming) GUI.Label(r, "RA", Styles.animatedIndicatorStyle);
else GUI.Label(r, "A", Styles.animatedIndicatorStyle);
}

private void DrawPresetProperty()
{
Rect r = new Rect(2, DrawingData.TooltipCheckRect.y + 2, 8, 16);
Rect r = new Rect(3, DrawingData.IconsPositioningHeight, 8, 16);
//GUI.DrawTexture(r, Styles.texture_preset, ScaleMode.StretchToFill, true);
GUI.Label(r, "P", Styles.cyanStyle);
GUI.Label(r, "P", Styles.presetIndicatorStyle);
}

protected void ExecuteOnValueActions(Material[] targets)
Expand Down Expand Up @@ -501,23 +505,49 @@ public override void CopyToMaterial(Material m, bool isTopCall = false)

public override void DrawInternal(GUIContent content, CRect rect = null, bool useEditorIndent = false, bool isInHeader = false)
{
if(Options.margin_top > 0)
{
GUILayoutUtility.GetRect(0, Options.margin_top);
}

bool doExpand = Options.condition_expand.Test();
if(Options.draw_border)
{
bool has_header = string.IsNullOrWhiteSpace(this.Content.text) == false;
int headerXOffset = 0;
ShaderProperty reference = Options.reference_property != null ? ActiveShaderEditor.PropertyDictionary[Options.reference_property] : null;

Rect border = EditorGUILayout.BeginVertical();
GUILayoutUtility.GetRect(0, 5 + (has_header ? 20 : 0));
border = new RectOffset(this.XOffset * -15 - 12, 3, -2, -2).Add(border);
Vector4 borderWidths = new Vector4(3, (has_header ? 22 : 3), 3, 3);
GUI.DrawTexture(border, Texture2D.whiteTexture, ScaleMode.StretchToFill, true, 0, Styles.COLOR_BACKGROUND_1, borderWidths, 10);
if(doExpand)
{
// Draw as border line
Vector4 borderWidths = new Vector4(3, (has_header ? 22 : 3), 3, 3);
GUI.DrawTexture(border, Texture2D.whiteTexture, ScaleMode.StretchToFill, true, 0, Styles.COLOR_BACKGROUND_1, borderWidths, 10);
}else
{
// Draw as solid
GUI.DrawTexture(border, Texture2D.whiteTexture, ScaleMode.StretchToFill, true, 0, Styles.COLOR_BACKGROUND_1, Vector4.zero, 10);
}
if(reference != null)
{
Rect referenceRect = new Rect(border.x + 16, border.y + 2, 20, 20);
reference.Draw(new CRect(referenceRect), new GUIContent(), isInHeader: true, useEditorIndent: true);
headerXOffset = 16;
}
if(has_header)
{
Rect header = new Rect(border.x + 16, border.y, border.width - 16, 22);
Rect header = new Rect(border.x + 16 + headerXOffset, border.y, border.width - 16, 22);
GUI.Label(header, this.Content, EditorStyles.boldLabel);
}
}
foreach (ShaderPart part in parts)
if(doExpand)
{
part.Draw();
foreach (ShaderPart part in parts)
{
part.Draw();
}
}
if (Options.draw_border)
{
Expand Down Expand Up @@ -704,6 +734,7 @@ public void UpdateKeywordFromValue()
void InitializeDrawers()
{
DrawingData.ResetLastDrawerData();
DrawingData.IsCollectingProperties = true;
ShaderEditor.Active.Editor.GetPropertyHeight(MaterialProperty, MaterialProperty.displayName);

this.IsAnimatable = !DrawingData.LastPropertyDoesntAllowAnimation;
Expand Down Expand Up @@ -744,6 +775,8 @@ void InitializeDrawers()

this.IsAnimated = IsAnimatable && tag != "";
this.IsRenaming = IsAnimatable && tag == "2";

DrawingData.IsCollectingProperties = false;
}

public override void DrawInternal(GUIContent content, CRect rect = null, bool useEditorIndent = false, bool isInHeader = false)
Expand Down
30 changes: 23 additions & 7 deletions _PoiyomiShaders/Scripts/ThryEditor/Editor/GUIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static void SmallTextureProperty(Rect position, MaterialProperty prop, GU
thumbnailPos.width -= 20;
}
editor.TexturePropertyMiniThumbnail(thumbnailPos, prop, label.text, label.tooltip);
float iconsPositioningHeight = thumbnailPos.y;
//VRAM
Rect vramPos = Rect.zero;
if (DrawingData.CurrentTextureProperty.MaterialProperty.textureValue != null)
Expand Down Expand Up @@ -102,7 +103,9 @@ public static void SmallTextureProperty(Rect position, MaterialProperty prop, GU
{
EditorGUI.showMixedValue = ShaderEditor.Active.Materials.Select(m => m.GetTextureScale(prop.name)).Distinct().Count() > 1 || ShaderEditor.Active.Materials.Select(m => m.GetTextureOffset(prop.name)).Distinct().Count() > 1;
ShaderEditor.Active.Editor.TextureScaleOffsetProperty(prop);
tooltipRect.height += GUILayoutUtility.GetLastRect().height;
Rect lastRect = GUILayoutUtility.GetLastRect();
tooltipRect.height = (lastRect.y - tooltipRect.y) + lastRect.height;
iconsPositioningHeight = lastRect.y;
}
//In case of locked material end disabled group here to allow editing of sub properties
if (ShaderEditor.Active.IsLockedMaterial) EditorGUI.EndDisabledGroup();
Expand Down Expand Up @@ -131,7 +134,8 @@ public static void SmallTextureProperty(Rect position, MaterialProperty prop, GU
Rect object_rect = new Rect(position);
object_rect.height = GUILayoutUtility.GetLastRect().y - object_rect.y + GUILayoutUtility.GetLastRect().height;
DrawingData.LastGuiObjectRect = object_rect;
DrawingData.TooltipCheckRect = tooltipRect;
DrawingData.TooltipCheckRect = tooltipRect;
DrawingData.IconsPositioningHeight = iconsPositioningHeight;

// Border Code start
if(isFoldedOut)
Expand Down Expand Up @@ -237,12 +241,13 @@ public static void StylizedBigTextureProperty(Rect position, MaterialProperty pr


//scale offset rect + foldout properties
Rect scale_offset_rect = new Rect();
scale_offset_rect = new RectOffset(30, 5, 37, 0).Remove(optionsSide);
scale_offset_rect.height = position.height;
if (hasFoldoutProperties || DrawingData.CurrentTextureProperty.Options.reference_property != null)
{
if (DrawingData.CurrentTextureProperty.hasScaleOffset)
{
Rect scale_offset_rect = new RectOffset(30, 5, 37, 0).Remove(optionsSide);
scale_offset_rect.height = position.height;
EditorGUI.showMixedValue = ShaderEditor.Active.Materials.Select(m => m.GetTextureScale(prop.name)).Distinct().Count() > 1 || ShaderEditor.Active.Materials.Select(m => m.GetTextureOffset(prop.name)).Distinct().Count() > 1;
editor.TextureScaleOffsetProperty(scale_offset_rect, prop);
}
Expand Down Expand Up @@ -290,7 +295,8 @@ public static void StylizedBigTextureProperty(Rect position, MaterialProperty pr
GUI.Label(label_rect, label);

DrawingData.LastGuiObjectRect = border;
DrawingData.TooltipCheckRect = border;
DrawingData.TooltipCheckRect = Rect.MinMaxRect(position.x, position.y, scale_offset_rect.xMax, scale_offset_rect.yMax);
DrawingData.IconsPositioningHeight = scale_offset_rect.y;
}

public static void BigTexturePropertyBasic(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool hasFoldoutProperties, bool skip_drag_and_drop_handling = false)
Expand All @@ -303,8 +309,14 @@ public static void BigTexturePropertyBasic(Rect position, MaterialProperty prop,
}
GUILayoutUtility.GetRect(0, EditorGUIUtility.singleLineHeight * 3 - 5);
editor.TextureProperty(position, prop, text);
DrawingData.LastGuiObjectRect = position;
DrawingData.TooltipCheckRect = position;

Rect tooltipCheckRect = position;
tooltipCheckRect.height += EditorGUIUtility.singleLineHeight * 3 - 5;

float iconsPositioningHeight = position.y;
if(DrawingData.CurrentTextureProperty.hasScaleOffset)
iconsPositioningHeight += position.height + EditorGUIUtility.singleLineHeight - 5;


// Reference properties
EditorGUI.indentLevel += 1;
Expand All @@ -321,6 +333,10 @@ public static void BigTexturePropertyBasic(Rect position, MaterialProperty prop,
property.Draw(useEditorIndent: true);
}
EditorGUI.indentLevel -= 1;

DrawingData.LastGuiObjectRect = position;
DrawingData.TooltipCheckRect = tooltipCheckRect;
DrawingData.IconsPositioningHeight = iconsPositioningHeight;
}

public static void OpenTexturePicker(MaterialProperty prop)
Expand Down
11 changes: 10 additions & 1 deletion _PoiyomiShaders/Scripts/ThryEditor/Editor/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,19 @@ public static void SetMaterialValue(string key, string value)
{
foreach (Material m in materials) m.renderQueue = q;
}
}else if (key == "render_type")
}
else if (key == "render_type")
{
foreach (Material m in materials) m.SetOverrideTag("RenderType", value);
}
else if (key == "preview_type")
{
foreach (Material m in materials) m.SetOverrideTag("PreviewType", value);
}
else if (key == "ignore_projector")
{
foreach (Material m in materials) m.SetOverrideTag("IgnoreProjector", value);
}
}

public static void SetMaterialPropertyValue(MaterialProperty p, string value)
Expand Down

0 comments on commit 2c7f7a0

Please sign in to comment.