Skip to content

Commit

Permalink
A bit of reordering and fix recipe inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Nov 6, 2023
1 parent fd2cf51 commit 1c8afac
Show file tree
Hide file tree
Showing 37 changed files with 105 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ public class ModRegistryItemInspector : TriEditor
private void Awake()
{
_toggle = new GUIStyle(EditorStyles.toggle);
_toggle.normal.textColor = Color.red;
_toggle.hover.textColor = Color.red;
_toggle.focused.textColor = Color.red;
_toggle.active.textColor = Color.red;
_toggle.onNormal.textColor = Color.green;
_toggle.onHover.textColor = Color.green;
_toggle.onFocused.textColor = Color.green;
_toggle.onActive.textColor = Color.green;
_toggle.normal.textColor = _toggle.hover.textColor = _toggle.focused.textColor = _toggle.active.textColor = Color.red;
_toggle.onNormal.textColor = _toggle.onHover.textColor = _toggle.onFocused.textColor = _toggle.onActive.textColor = Color.green;
}

protected override void OnHeaderGUI()
Expand All @@ -33,7 +27,7 @@ protected override void OnHeaderGUI()
bool isInRegistry = ModRegistry.Instance.registryItems.Contains(item);
bool isSomehowInRegistry = ModRegistry.Instance.Flatten().Contains(item);

Rect position = new Rect(46, 24, 105, 15);
Rect position = new(46, 24, 105, 15);

if (!isInRegistry && isSomehowInRegistry)
{
Expand Down
2 changes: 1 addition & 1 deletion Unity/Assets/Editor/Scripts/Inspectors/RecipeInspector.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Editor.Scripts.PropertyDrawers;
using Editor.Scripts.PropertyDrawers.Enums;
using SCHIZO.Items.Data.Crafting;
using TriInspector.Editors;
using UnityEditor;
Expand Down
3 changes: 3 additions & 0 deletions Unity/Assets/Editor/Scripts/PropertyDrawers/Attributes.meta

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

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Reflection;
using Editor.Scripts.PropertyDrawers.Objects;
using Editor.Scripts.PropertyDrawers.Utilities;
using HarmonyLib;
using SCHIZO.Attributes;
using SCHIZO.Items.Data.Crafting;
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Attributes
{
[CustomPropertyDrawer(typeof(CarefulAttribute))]
public sealed class CarefulAttributeDrawer : PropertyDrawer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using Editor.Scripts.PropertyDrawers.Utilities;
using SCHIZO.Attributes;
using SCHIZO.Helpers;
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Attributes
{
[CustomPropertyDrawer(typeof(ExposedTypeAttribute))]
public sealed class ExposedTypeAttributeDrawer : PropertyDrawer
Expand Down
3 changes: 3 additions & 0 deletions Unity/Assets/Editor/Scripts/PropertyDrawers/Enums.meta

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

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SCHIZO.Interop.Subnautica.Enums;
using UnityEditor;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Enums
{
[CustomPropertyDrawer(typeof(CraftTree_Type_All))]
public sealed class CraftTree_Type_AllDrawer : GameSpecificEnumDrawer<CraftTree_Type_All>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SCHIZO.Interop.Subnautica.Enums;
using UnityEditor;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Enums
{
[CustomPropertyDrawer(typeof(EcoTargetType_All))]
public sealed class EcoTargetType_AllDrawer : GameSpecificEnumDrawer<EcoTargetType_All>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Editor.Scripts.PropertyDrawers.Utilities;
using SCHIZO.Registering;
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Enums
{
public abstract class GameSpecificEnumDrawer<T> : PropertyDrawer where T : Enum
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Enums
{
[CustomPropertyDrawer(typeof(TechType_All))]
public sealed class TechType_AllDrawer : GameSpecificEnumDrawer<TechType_All>
Expand Down
3 changes: 3 additions & 0 deletions Unity/Assets/Editor/Scripts/PropertyDrawers/Objects.meta

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

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using SCHIZO.Registering;
using Editor.Scripts.PropertyDrawers.Utilities;
using SCHIZO.Registering;
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Objects
{
[CustomPropertyDrawer(typeof(Game))]
public sealed class GameDrawer : PropertyDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Objects
{
[CustomPropertyDrawer(typeof(HullPlate))]
public sealed class HullPlateDrawer : PropertyDrawer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using SCHIZO.Items.Data.Crafting;
using Editor.Scripts.PropertyDrawers.Utilities;
using SCHIZO.Items.Data.Crafting;
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Objects
{
[CustomPropertyDrawer(typeof(Ingredient))]
public sealed class IngredientDrawer : PropertyDrawer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using SCHIZO.Items.Data;
using Editor.Scripts.PropertyDrawers.Enums;
using Editor.Scripts.PropertyDrawers.Utilities;
using SCHIZO.Items.Data;
using SCHIZO.Items.Data.Crafting;
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Objects
{
[CustomPropertyDrawer(typeof(Item))]
public sealed class ItemDrawer : PropertyDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Objects
{
[CustomPropertyDrawer(typeof(Recipe))]
public sealed class RecipeDrawer : PropertyDrawer
Expand Down
3 changes: 3 additions & 0 deletions Unity/Assets/Editor/Scripts/PropertyDrawers/Utilities.meta

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using UnityEngine;
using Object = UnityEngine.Object;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Utilities
{
public static class DrawerUtils
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using UnityEditor;
using UnityEngine;

namespace Editor.Scripts.PropertyDrawers
namespace Editor.Scripts.PropertyDrawers.Utilities
{
public class SearchablePopup : PopupWindowContent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ namespace SCHIZO.Interop.Subnautica.Enums
{
public enum EcoTargetType_All
{
[Game(Game.Both)] None = 0,
[Game(Game.Both)] Shiny = 1,
[Game(Game.Both)] DeadMeat = 2,
[Game(Game.Both)] Coral = 3,
[Game(Game.Both)] HeatArea = 4,
[Game(Game.Both)] Tech = 100, // 0x00000064
[Game(Game.Both)] Fragment = 150, // 0x00000096
[Game(Game.Both)] HoleFish = 1000, // 0x000003E8
[Game(Game.Both)] HoopFish = 1010, // 0x000003F2
[Game(Game.Both)] Peeper = 1020, // 0x000003FC
[Game(Game.Both)] Oculus = 1030, // 0x00000406
[Game(Game.Both)] SpadeFish = 1040, // 0x00000410
[Game(Game.Both)] CuteFish = 1050, // 0x0000041A
[Game(Game.Both)] LavaLarva = 1060, // 0x00000424
[Game(Game.Both)] Biter = 1070, // 0x0000042E
[Game(Game.Both)] Mushroom = 2000, // 0x000007D0
[Game(Game.Both)] HeatSource = 2005, // 0x000007D5
[Game(Game.Both)] SmallFish = 2010, // 0x000007DA
[Game(Game.Both)] MediumFish = 2020, // 0x000007E4
[Game(GameX.Both)] None = 0,
[Game(GameX.Both)] Shiny = 1,
[Game(GameX.Both)] DeadMeat = 2,
[Game(GameX.Both)] Coral = 3,
[Game(GameX.Both)] HeatArea = 4,
[Game(GameX.Both)] Tech = 100, // 0x00000064
[Game(GameX.Both)] Fragment = 150, // 0x00000096
[Game(GameX.Both)] HoleFish = 1000, // 0x000003E8
[Game(GameX.Both)] HoopFish = 1010, // 0x000003F2
[Game(GameX.Both)] Peeper = 1020, // 0x000003FC
[Game(GameX.Both)] Oculus = 1030, // 0x00000406
[Game(GameX.Both)] SpadeFish = 1040, // 0x00000410
[Game(GameX.Both)] CuteFish = 1050, // 0x0000041A
[Game(GameX.Both)] LavaLarva = 1060, // 0x00000424
[Game(GameX.Both)] Biter = 1070, // 0x0000042E
[Game(GameX.Both)] Mushroom = 2000, // 0x000007D0
[Game(GameX.Both)] HeatSource = 2005, // 0x000007D5
[Game(GameX.Both)] SmallFish = 2010, // 0x000007DA
[Game(GameX.Both)] MediumFish = 2020, // 0x000007E4
[Game(Game.BelowZero)] FishSchool = 2025, // 0x000007E9
[Game(Game.Both)] Shark = 2030, // 0x000007EE
[Game(Game.Both)] Whale = 2040, // 0x000007F8
[Game(Game.Both)] Leviathan = 2045, // 0x000007FD
[Game(Game.Both)] Poison = 2050, // 0x00000802
[Game(Game.Both)] Trap = 2060, // 0x0000080C
[Game(Game.Both)] Cure = 2070, // 0x00000816
[Game(Game.Both)] CuredWarp = 2080, // 0x00000820
[Game(Game.Both)] SubDecoy = 2090, // 0x0000082A
[Game(GameX.Both)] Shark = 2030, // 0x000007EE
[Game(GameX.Both)] Whale = 2040, // 0x000007F8
[Game(GameX.Both)] Leviathan = 2045, // 0x000007FD
[Game(GameX.Both)] Poison = 2050, // 0x00000802
[Game(GameX.Both)] Trap = 2060, // 0x0000080C
[Game(GameX.Both)] Cure = 2070, // 0x00000816
[Game(GameX.Both)] CuredWarp = 2080, // 0x00000820
[Game(GameX.Both)] SubDecoy = 2090, // 0x0000082A
}
}
20 changes: 20 additions & 0 deletions Unity/Assets/Scripts/SCHIZO/Items/Data/Crafting/Recipe.Unity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using HarmonyLib;
using JetBrains.Annotations;
using UnityEditor;

namespace SCHIZO.Items.Data.Crafting
{
partial class Recipe
{
#if UNITY_EDITOR
private static readonly FieldInfo _activeGame = AccessTools.Field(AccessTools.TypeByName("TechType_AllDrawer"), "TargetGame");

[UsedImplicitly]
private void OnGameChanged()
{
if (Selection.activeObject == this) _activeGame.SetValue(null, game);
}
#endif
}
}

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

7 changes: 6 additions & 1 deletion Unity/Assets/Scripts/SCHIZO/Items/Data/Crafting/Recipe.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using SCHIZO.Registering;
using System.Reflection;
using HarmonyLib;
using JetBrains.Annotations;
using SCHIZO.Registering;
using TriInspector;
using UnityEditor;
using UnityEngine;

namespace SCHIZO.Items.Data.Crafting
{
[CreateAssetMenu(menuName = "SCHIZO/Items/Recipe")]
public sealed partial class Recipe : ScriptableObject
{
[OnValueChanged("OnGameChanged")]
public Game game = Game.Subnautica | Game.BelowZero;

public int craftAmount = 1;
Expand Down
19 changes: 9 additions & 10 deletions Unity/Assets/Scripts/SCHIZO/Registering/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
namespace SCHIZO.Registering
{
[AttributeUsage(AttributeTargets.Field)]
public sealed class GameAttribute : Attribute
public sealed class GameAttribute(Game game) : Attribute
{
public readonly Game game;
public readonly Game game = game;

public GameAttribute(Game game)
{
this.game = game;
}

public GameAttribute() : this(Game.Any) { }
public GameAttribute() : this(GameX.Any) { }
}

[Flags]
public enum Game
{
Any = 0,
Subnautica = 1,
BelowZero = 2,
Both = Subnautica | BelowZero,
}

public static class GameX
{
public const Game Any = 0;
public const Game Both = Game.Subnautica | Game.BelowZero;
}
}

0 comments on commit 1c8afac

Please sign in to comment.