Example #1
0
        /// <summary>
        /// Changes the last shown text to the given text.
        /// </summary>
        public static void ChangeLastText(string text)
        {
            var data = DataHolder.TerminalData;

            if (data.Batching)
            {
                if (data.BatchEntries.Count == 0)
                {
                    ShowText(text);
                }
                else
                {
                    var entry = SList.Peek(data.BatchEntries);
                    DebugUtil.Assert(entry.Texts.Length > 1, "Changing last text as a single text but last text is not a single text!");
                    entry.Texts[0] = text;
                }
            }
            else
            {
                var allEntries = DataHolder.TerminalData.AllEntries;
                if (allEntries.Count == 0)
                {
                    ShowText(text);
                }
                else
                {
                    var lastEntry = SList.Peek(allEntries);
                    DebugUtil.Assert(lastEntry.EntryType != TerminalEntryType.SingleText, "Changing last text as a single text but last text is not a single text!");
                    var textEntry = lastEntry.SceneObject.GetComponent <SingleTextEntry>();
                    textEntry.TextComponent.text = text;
                }
            }
        }
Example #2
0
        public static Window GetWindowFromWindowComponent(WindowComponent windowComponent)
        {
            var window = SList.Find(CurrentlyOpenWindows, w => w.SceneWindow == windowComponent);

            DebugUtil.Assert(window == null, "CLOSING A INVALID WINDOW");
            return(window);
        }
Example #3
0
        /// <summary>
        /// Ends and executes the current text batch.
        /// </summary>
        public static void EndTextBatch()
        {
            var data = DataHolder.TerminalData;

            DebugUtil.Assert(!data.Batching, "THERE'S NO TEXT BATCH HAPPENING!");

            data.Batching = false;
            while (data.BatchEntries.Count > 0)
            {
                var entry = SList.Dequeue(data.BatchEntries);
                switch (entry.EntryType)
                {
                case TerminalEntryType.SingleText:
                    ShowText(entry.Texts[0]);
                    break;

                case TerminalEntryType.DualText:
                    ShowDualText(entry.Texts[0], entry.Texts[1]);
                    break;

                default:
                    DebugUtil.Log(string.Format("THE TEXT ENTRY TYPE {0} IS NOT IMPLEMENTED!", entry.EntryType),
                                  Color.red, DebugUtil.DebugCondition.Always, DebugUtil.LogType.Info);
                    break;
                }
            }

            UpdateTableAndScroll();
        }
Example #4
0
        public static void Setup(Object aditionalContent)
        {
            var gsmWatcherDevices = aditionalContent as TextAsset;

            DebugUtil.Assert(gsmWatcherDevices == null, "The aditional content of the GSM Watche is not a text watcher.");
            DevicesData = gsmWatcherDevices.text;
        }
Example #5
0
        /// <summary>
        /// Calls resource load with the given path.
        /// </summary>
        public static T Load <T>(string assetPath) where T : UnityEngine.Object
        {
            var asset = Resources.Load <T>(assetPath);

            DebugUtil.Assert(asset == null, string.Format("No asset of type '{0}' found at path '{1}'.", typeof(T).Name, assetPath));
            return(asset);
        }
Example #6
0
        /// <summary>
        /// Calculates and stores the sizes of the items of the given line accordingly to the maxLineSize and items weight.
        /// </summary>
        public static TextTableLine CalculateIdealTableItemSize(TextTableLine line)
        {
            int maxLineSize = line.MaxLineSize;

            // If no max line size was defined, do nothing
            if (maxLineSize <= 0)
            {
                return(line);
            }

            int separatorLength = 0;

            if (!string.IsNullOrEmpty(line.ItemsSeparator))
            {
                separatorLength = line.ItemsSeparator.Length;
            }

            maxLineSize -= separatorLength * (line.Items.Count - 1);

            if (line.AddSeparatorOnStart)
            {
                maxLineSize -= separatorLength;
            }
            if (line.AddSeparatorOnEnd)
            {
                maxLineSize -= separatorLength;
            }

            DebugUtil.Assert(maxLineSize <= 0, "THE MAX LINE SIZE IS NOT BIG ENOUGH TO FIT ANY OF THE ITEMS");

            for (int i = 0; i < line.Items.Count; i++)
            {
                var item   = line.Items[i];
                var weight = item.WeightOnLine;

                int size;
                if (Mathf.Approximately(weight, 0f))
                {
                    size = item.Text.Length; // assume natural size
                }
                else
                {
                    size = Mathf.RoundToInt(maxLineSize * weight);
                }

                if (line.MaxLineSizeIsForced)
                {
                    item.Size = size;
                }
                else
                {
                    item.Size = Math.Min(item.Size, size);
                }

                line.Items[i] = item;
            }

            return(line);
        }
Example #7
0
        public static void Init()
        {
            DebugUtil.Assert(Instance != null, "LoopUtil.Init being called multiple times!");

            Instance            = new GameObject("LOOP-UTIL").AddComponent <LoopUtil>();
            UpdateCallbacks     = SList.Create <Action>(5);
            LateUpdateCallbacks = SList.Create <Action>(3);
        }
Example #8
0
        void Bake()
        {
            GUIReferences.InputListener = FindObjectOfType <InputListener>();
            DebugUtil.Assert(GUIReferences.InputListener == null, "DID NOT FOUND INPUTLISTENER. IS IT ACTIVE ON THE SCENE?");

            GUIReferences.TerminalComponent = FindObjectOfType <TerminalComponent>();
            DebugUtil.Assert(GUIReferences.TerminalComponent == null, "DID NOT FOUND TERMINALCOMPONENT. IS IT ACTIVE ON THE SCENE?");
        }
Example #9
0
        /// <summary>
        /// Starts a text batch.
        /// The text will only be shown on the screen after you call EndTextBatch.
        /// </summary>
        public static void StartTextBatch()
        {
            var data = DataHolder.TerminalData;

            DebugUtil.Assert(data.Batching, "THERE'S ALREADY A TEXT BATCH HAPPENING!");

            data.Batching = true;
        }
Example #10
0
        /// <summary>
        /// Formats a table item accordingly to the given option. The text should be without any modifiers or colors.
        /// It  also stores the returned result on the ModifiedText property of the item after applying the modifiers.
        /// </summary>
        public static string FormatTableItem(TextTableColumn column)
        {
            const int AddDotWrapCount = 3;

            string text = column.Text;

            if (text.Length > column.Size)
            {
                switch (column.WrapMode)
                {
                case WrapTextMode.Clamp:
                    text = text.Substring(0, column.Size);
                    break;

                case WrapTextMode.AddDots:
                    DebugUtil.Assert(text.Length <= 3, "TO USE ADD POINTS WRAP THE TEXT MUST BE AT LEAST 3 CHARS LONG");
                    text = text.Substring(0, column.Size - AddDotWrapCount);
                    text = text.PadRight(column.Size, '.');
                    break;
                }
            }

            var diff = column.Size - column.Text.Length;

            if (diff > 0)
            {
                switch (column.Align)
                {
                case TextTableAlign.Left:
                    text = text.PadRight(column.Size, column.PaddingChar);
                    break;

                case TextTableAlign.Center:
                    if (diff % 2 != 0)
                    {
                        diff++;
                        column.Size++;     // need to add one here to compensate for the one padding we are adding
                    }
                    diff /= 2;
                    text  = text.PadLeft(column.Size - diff, column.PaddingChar);
                    text  = text.PadRight(column.Size, column.PaddingChar);
                    break;

                case TextTableAlign.Right:
                    text = text.PadLeft(column.Size, column.PaddingChar);
                    break;
                }
            }

            text = ModifyText(text, column.ModifyTextOptions);
            column.ModifiedText = text;
            return(text);
        }
Example #11
0
        public static void Setup(Object aditionalData)
        {
            AditionalData = aditionalData as MapAditionalData;
            DebugUtil.Assert(AditionalData == null, "MapProgram's aditional data is not a MapAditionalData!");

            LatitudeValidation = new CommandLineArgValidationOption();
            LatitudeValidation.ArgumentName = LatitudeParameterName;
            LatitudeValidation.Requirements = ArgRequirement.Required | ArgRequirement.ValueRequired;

            LongitudeValidation = new CommandLineArgValidationOption();
            LongitudeValidation.ArgumentName = LongitudeParameterName;
            LongitudeValidation.Requirements = ArgRequirement.Required | ArgRequirement.ValueRequired;

            Validations = new[] { LatitudeValidation, LongitudeValidation };
        }
Example #12
0
        /// <summary>
        /// Returns a list containing all of the dir files.
        /// </summary>
        public static void CacheDirFiles(HashDir dir)
        {
            SList.Clear(dir.Files);
            for (int i = 0; i < dir.FilesId.Count; i++)
            {
                var fileId = dir.FilesId[i];
                var file   = FindFileById(fileId);
                DebugUtil.Assert(file == null, string.Format("THE DIR {0} HAS A INVALID FILE {1}", dir.Name, fileId));

                file.ParentDirId = dir.DirId;
                file.ParentDir   = dir;

                SList.Add(dir.Files, file);
            }
        }
Example #13
0
        /// <summary>
        /// Cache the dirs children based on the ChildsDirid values.
        /// </summary>
        public static void CacheDirChildren(HashDir dir)
        {
            SList.Clear(dir.Childs);
            for (int i = 0; i < dir.ChildsDirId.Count; i++)
            {
                var childId = dir.ChildsDirId[i];
                var child   = FindDirById(childId);

                DebugUtil.Assert(child == null, string.Format("THE DIR {0} HAS A INVALID CHILD {1}", dir.Name, childId));

                child.ParentDirId = dir.DirId;
                child.ParentDir   = dir;

                SList.Add(dir.Childs, child);
            }
        }
Example #14
0
        /// <summary>
        /// Returns the file extension to the given file type.
        /// </summary>
        public static string GetFileExtension(HashFileType fileType)
        {
            switch (fileType)
            {
            case HashFileType.Text:
                return(TextFileExtension);

            case HashFileType.Image:
                return(ImageFileExtension);

            default:
                DebugUtil.Assert(true, "DID NOT FOUND AN EXTENSION FOR THE FILE TYPE: " + fileType);
                break;
            }

            return(string.Empty);
        }
Example #15
0
        /// <summary>
        /// Returns the method used to execute the given program.
        /// </summary>
        public static Action <ProgramExecutionOptions> GetProgramExecutionEntryPoint(Program program)
        {
            switch (program.ProgramType)
            {
            case ProgramType.Cd:
                return(CdProgram.Execute);

            case ProgramType.Dir:
                return(DirProgram.Execute);

            case ProgramType.Clear:
                return(ClearProgram.Execute);

            case ProgramType.Open:
                return(OpenProgram.Execute);

            case ProgramType.Cryptor:
                return(CryptorProgram.Execute);

            case ProgramType.Help:
                return(HelpProgram.Execute);

            case ProgramType.SSH:
                return(SSHProgram.Execute);

            case ProgramType.GSMWatcher:
                return(GSMWatcherProgram.Execute);

            case ProgramType.Map:
                return(MapProgram.Execute);

            case ProgramType.Print:
                return(PrintProgram.Execute);

            case ProgramType.Cracker:
                return(CrackerProgram.Execute);

            default:
                DebugUtil.Assert(true, "PROGRAM TYPE HAS NO RELATED CLASS. " + program.ProgramType);
                break;
            }

            return(null);
        }
Example #16
0
        private static IEnumerator InternalExecuteDreamOne()
        {
            PrepareForDream();

            var dreamOne  = DataHolder.DreamReferences.DreamOne;
            var sceneLoad = SceneManager.LoadSceneAsync(dreamOne.Scene, LoadSceneMode.Additive);

            yield return(AnnouncementUtil.RunAnnouncement(dreamOne.DreamAnnouncement));

            yield return(sceneLoad);

            AnnouncementUtil.HideAnnouncement();

            var dreamOneComponent = GameObject.FindObjectOfType <DreamOneReferences>();

            DebugUtil.Assert(dreamOneComponent == null, "No dream one component on dream one scene!");

            DreamOneController.Run(dreamOneComponent, EndDreamOne);
        }
Example #17
0
        /// <summary>
        /// Calculates and return the full path of the dir.
        /// </summary>
        public static string GetDirFullPath(HashDir hashDir)
        {
            var    dir = hashDir;
            string path;

            // Root folder is treated differently
            if (dir.ParentDirId == -1)
            {
                DebugUtil.Assert(dir.Name != PathUtil.PathSeparator, string.Format("THE DIR {0} HAS NO PARENT AND IT'S THE ROOT DIR!", dir.DirId));
                path = dir.Name;
            }
            else
            {
#if DEB
                if (dir.ParentDirId == dir.DirId)
                {
                    DebugUtil.Log(string.Format("THE DIR {0} HAS ITSELF AS PARENT!", dir.DirId), Color.red, DebugUtil.DebugCondition.Always,
                                  DebugUtil.LogType.Info);
                    return(null);
                }
#endif
                var pathStack = SList.Create <string>(5);
                SList.Clear(pathStack);
                while (dir.ParentDirId != -1)
                {
                    SList.Push(pathStack, dir.Name);
                    dir = FindDirById(dir.ParentDirId);
                }

                var builder = new StringBuilder(pathStack.Count * 10);
                while (pathStack.Count > 0)
                {
                    var last = SList.Pop(pathStack);
                    builder.Append(PathUtil.AddSeparatorToStart(last));
                }
                path = builder.ToString();

                // since it's a folder, add slash to the end of it
                path = PathUtil.AddSeparatorToEnd(path);
            }

            return(path);
        }
Example #18
0
        public static string ApplyRichTextModifiers(string text, int modifiers)
        {
            var builder = new StringBuilder(text.Length + 12);

            if (MathUtil.ContainsFlag(modifiers, TextModifiers.Bold))
            {
                text = string.Format(RichTextBoldStringFormat, text);
            }

            if (MathUtil.ContainsFlag(modifiers, TextModifiers.Italic))
            {
                text = string.Format(RichTextItalicStringFormat, text);
            }

            DebugUtil.Assert(MathUtil.ContainsFlag(modifiers, TextModifiers.Ignorecolor), "IGNORE COLOR IS NOT A VALID RICH TEXT MODIFIER!");
            DebugUtil.Assert(MathUtil.ContainsFlag(modifiers, TextModifiers.Stroke), "STROKE IS NOT A VALID RICH TEXT MODIFIER!");
            DebugUtil.Assert(MathUtil.ContainsFlag(modifiers, TextModifiers.Underline), "UNDERLINE IS NOT A VALID RICH TEXT MODIFIER!");

            var builderText = builder.ToString();

            return(builderText);
        }