< Summary

Class:GDX.Developer.ConsoleVariableBase
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleVariableBase.cs
Covered lines:0
Uncovered lines:24
Coverable lines:24
Total lines:80
Line coverage:0% (0 of 24)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:6
Method coverage:0% (0 of 6)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetAccessLevel()0%2100%
ConsoleVariableBase(...)0%2100%
GetArgumentAutoCompleteSuggestions(...)0%6200%
GetName()0%2100%
GetDescription()0%2100%
GetFlags()0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleVariableBase.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6
 7namespace GDX.Developer
 8{
 9#if UNITY_2022_2_OR_NEWER
 10    public abstract class ConsoleVariableBase
 11    {
 12        public enum ConsoleVariableType
 13        {
 14            String,
 15            Integer,
 16            Float,
 17            Boolean
 18        }
 19
 20        [Flags]
 21        public enum ConsoleVariableFlags
 22        {
 23            None = 0x0,
 24            Setting = 0x1,
 25            Cheat = 0x2
 26        }
 27
 28        readonly ConsoleVariableFlags m_Flags;
 29        readonly string m_Name;
 30        readonly string m_Description;
 31
 32        /// <summary>
 33        ///     Returns the minimum access level required to set a variable.
 34        /// </summary>
 35        /// <remarks>Overrideable, but defaults to having user level access.</remarks>
 36        /// <returns>The required user access level to alter a variable.</returns>
 37        public virtual Console.ConsoleAccessLevel GetAccessLevel()
 038        {
 039            return Console.ConsoleAccessLevel.Anonymous;
 040        }
 41
 42        public abstract ConsoleVariableType GetConsoleVariableType();
 43        public abstract object GetBoxedValue();
 44        public abstract void SetValueFromString(string newValue);
 45        public abstract string GetCurrentValueAsString();
 46        public abstract string GetDefaultValueAsString();
 47
 048        protected ConsoleVariableBase(string name, string description, ConsoleVariableFlags flags)
 049        {
 050            m_Name = name;
 051            m_Description = description;
 052            m_Flags = flags;
 53
 054            Console.RegisterVariable(this);
 055        }
 56
 57        public virtual string[] GetArgumentAutoCompleteSuggestions(string hint, string[] existingSet = null)
 058        {
 059            string defaultValue = GetDefaultValueAsString();
 060            if (hint == defaultValue) return null;
 061            return new string[] { defaultValue };
 062        }
 63
 64        public string GetName()
 065        {
 066            return m_Name;
 067        }
 68
 69        public string GetDescription()
 070        {
 071            return m_Description;
 072        }
 73
 74        public ConsoleVariableFlags GetFlags()
 075        {
 076            return m_Flags;
 077        }
 78    }
 79#endif // UNITY_2022_2_OR_NEWER
 80}