Skip to content

Commit

Permalink
[feat, fix, refactor] Streamlined a bunch of functions and added a lo…
Browse files Browse the repository at this point in the history
…g functionality
  • Loading branch information
Owmacohe committed Apr 18, 2024
1 parent 07710ed commit 96e1e3b
Show file tree
Hide file tree
Showing 60 changed files with 720 additions and 316 deletions.
3 changes: 2 additions & 1 deletion Components/Default/ChangedChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(float.PositiveInfinity), NodeType(DescantNodeType.Choice)]
public class ChangedChoice : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/ChangedResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(float.PositiveInfinity), NodeType(DescantNodeType.Response)]
public class ChangedResponse : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

using System;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(float.PositiveInfinity), NodeType(DescantNodeType.Any)]
public class Event : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/Interruptable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

using System;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(float.PositiveInfinity), NodeType(DescantNodeType.Response)]
public class Interruptable : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/LockedChoice.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Please see https://omch.tech/descant/#lockedchoice for documentation

using System;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(Single.PositiveInfinity), NodeType(DescantNodeType.Choice)]
public class LockedChoice : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

using System;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(float.PositiveInfinity), NodeType(DescantNodeType.Any)]
public class Log : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/PortraitChange.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Please see https://omch.tech/descant/#portraitchange for documentation

using System;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(Single.PositiveInfinity), NodeType(DescantNodeType.Any)]
public class PortraitChange : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/RandomizedChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
using System;
using System.Collections.Generic;
using Random = UnityEngine.Random;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(1), NodeType(DescantNodeType.Choice)]
public class RandomizedChoice : DescantComponent // TODO: make this always last
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/RelationshipChange.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Please see https://omch.tech/descant/#relationshipchange for documentation

using System;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(Single.PositiveInfinity), NodeType(DescantNodeType.Any)]
public class RelationshipChange : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/StatisticChange.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Please see https://omch.tech/descant/#statisticchange for documentation

using System;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(Single.PositiveInfinity), NodeType(DescantNodeType.Any)]
public class StatisticChange : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/StatisticReveal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

using System;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(Single.PositiveInfinity), NodeType(DescantNodeType.Any)]
public class StatisticReveal : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/TimedChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

using System;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(1), NodeType(DescantNodeType.Choice)]
public class TimedChoice : DescantComponent
Expand Down
3 changes: 2 additions & 1 deletion Components/Default/TopicChange.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Please see https://omch.tech/descant/#topicchange for documentation

using System;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
[Serializable, MaxQuantity(Single.PositiveInfinity), NodeType(DescantNodeType.Response)]
public class TopicChange : DescantComponent
Expand Down
4 changes: 2 additions & 2 deletions Components/DescantActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using System.Collections.Generic;
using UnityEngine;

namespace DescantComponents
namespace Descant.Components
{
/// <summary>
/// A data class representing an actor (player or NPC) in a Descant Dialogue
/// </summary>
[Serializable, CreateAssetMenu]
[Serializable, CreateAssetMenu(menuName = "Descant/Actor")]
public class DescantActor : ScriptableObject
{
/// <summary>
Expand Down
6 changes: 4 additions & 2 deletions Components/DescantComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using UnityEngine;
using Descant.Utilities;

namespace DescantComponents
namespace Descant.Components
{
/// <summary>
/// Descant node Component parent class
Expand All @@ -11,7 +13,7 @@ public abstract class DescantComponent
/// <summary>
/// Whether this Component is currently collapsed in the UI
/// </summary>
public bool Collapsed;
[HideInInspector] public bool Collapsed;

/// <summary>
/// Called when the node to which this Component is attached is reached in the dialogue
Expand Down
3 changes: 2 additions & 1 deletion Components/DescantComponentUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Descant.Utilities;
using System.Reflection;
using UnityEngine;

namespace DescantComponents
namespace Descant.Components
{
public static class DescantComponentUtilities
{
Expand Down
2 changes: 1 addition & 1 deletion Components/DescantNodeInvokeResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace DescantComponents
namespace Descant.Components
{
/// <summary>
/// Enum of DescantActors' variable types
Expand Down
2 changes: 1 addition & 1 deletion Documentation/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Add `DescantIfNode`
- ~~Make script calling easier~~
- Make autosave better (removed temporarily)
- Create log system
- ~~Create log system~~
- ~~Create an online Component documentation website~~
- Ctrl-S saving functionality for editors
- Save panned position in `Descant Graph Editor`
18 changes: 9 additions & 9 deletions Editor/Data/DescantGraph.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using DescantComponents;
using Descant.Components;
using UnityEngine;

namespace DescantEditor
namespace Descant.Editor
{
/// <summary>
/// Serializable class to hold the data for saving and loading Descant graphs
/// </summary>
[Serializable, CreateAssetMenu]
[Serializable, CreateAssetMenu(menuName = "Descant/Graph")]
public class DescantGraph : ScriptableObject
{
/// <summary>
Expand All @@ -30,22 +30,22 @@ public class DescantGraph : ScriptableObject
/// <summary>
/// A unique ID number that will be applied to the next-created ChoiceNode
/// </summary>
public int ChoiceNodeID;
[HideInInspector] public int ChoiceNodeID;

/// <summary>
/// A unique ID number that will be applied to the next-created ResponseNode
/// </summary>
public int ResponseNodeID;
[HideInInspector] public int ResponseNodeID;

/// <summary>
/// A unique ID number that will be applied to the next-created EndNode
/// </summary>
public int EndNodeID;
[HideInInspector] public int EndNodeID;

/// <summary>
/// A unique ID number that will be applied to the next-created NodeGroup
/// </summary>
public int GroupID;
[HideInInspector] public int GroupID;

/// <summary>
/// The ChoiceNodes in the graph
Expand All @@ -70,12 +70,12 @@ public class DescantGraph : ScriptableObject
/// <summary>
/// The NodeGroups in the graph
/// </summary>
public List<DescantGroupData> Groups;
[HideInInspector] public List<DescantGroupData> Groups;

/// <summary>
/// The connections between Nodes in the graph
/// </summary>
public List<DescantConnectionData> Connections;
[HideInInspector] public List<DescantConnectionData> Connections;

/// <summary>
/// Parameterized constructor
Expand Down
107 changes: 107 additions & 0 deletions Editor/Data/DescantLogData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using Descant.Utilities;
using UnityEngine;

namespace Descant.Editor
{
/// <summary>
/// Data file containing the log events for the Descant Log
/// </summary>
public class DescantLogData : ScriptableObject
{
/// <summary>
/// A DescantLogEvent's type
/// </summary>
public enum LogEventType { Begin, End, Node, Component }

/// <summary>
/// A simple class containing data from a single event within Descant
/// </summary>
[Serializable]
public class DescantLogEvent
{
/// <summary>
/// The time that the event occurred at (HH:MM:SS)
/// </summary>
public string Time;

/// <summary>
/// The type of the event
/// </summary>
public LogEventType Type;

/// <summary>
/// The subtype of the Event's type
/// (e.g. a ChoiceNode is a subtype of Node)
/// </summary>
public string Subtype;

/// <summary>
/// A name associated with the event
/// (e.g. the custom name given to a DescantNode in the Descant Graph Editor)
/// </summary>
public string Name;

/// <summary>
/// Parameterized constructor
/// </summary>
/// <param name="time">The time that the event occurred at</param>
/// <param name="type">The type of the event</param>
/// <param name="subtype">The subtype of the Event's type</param>
/// <param name="name">A name associated with the event</param>
public DescantLogEvent(string time, LogEventType type, string subtype, string name)
{
Time = time;
Type = type;
Subtype = subtype;
Name = name;

// Making sure to trim the subtype down to only the last name
if (Subtype.Contains('.'))
{
int startIndex = Subtype.LastIndexOf('.') + 1;
Subtype = Subtype.Substring(startIndex, Subtype.Length - startIndex);
}
}
}

/// <summary>
/// Whether or not to capture the Descant Log Events during runtime
/// </summary>
[HideInInspector] public bool Capture;

/// <summary>
/// The actual list of events that occurred the last time that the game was played
/// </summary>
[HideInInspector] public List<DescantLogEvent> Events = new List<DescantLogEvent>();

/// <summary>
/// Quick method to clear the file's data
/// </summary>
public void Clear()
{
Events = new List<DescantLogEvent>();

#if UNITY_EDITOR
DescantUtilities.SaveSerializedObject(this);
#endif
}

/// <summary>
/// Adds a new Descant Log Event to the list
/// </summary>
/// <param name="type">The type of the event</param>
/// <param name="subtype">The subtype of the Event's type</param>
/// <param name="name">A name associated with the event</param>
public void Log(LogEventType type, string subtype = "", string name = "")
{
if (Capture) Events.Add(new DescantLogEvent(
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second,
type,
subtype,
name
));
}
}
}
3 changes: 3 additions & 0 deletions Editor/Data/DescantLogData.cs.meta

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

Loading

0 comments on commit 96e1e3b

Please sign in to comment.