コード例 #1
0
 protected override void Initialize()
 {
     sman = new ScreenManager(this);
     Components.Add(sman);
     graphics.PreferMultiSampling = true;
     NameGenerator.init();
     Helpfile.init();
     FileEntry.init(Content);
     PatternDrawer.init(Content);
     ProgramList.init();
     Cube3D.Initilize(graphics.GraphicsDevice);
     base.Initialize();
 }
コード例 #2
0
ファイル: Game1.cs プロジェクト: hochladen/Hacknet
 protected override void Initialize()
 {
     this.sman = new ScreenManager((Game)this);
     this.Components.Add((IGameComponent)this.sman);
     this.graphics.PreferMultiSampling = true;
     NameGenerator.init();
     PatternDrawer.init(this.Content);
     ProgramList.init();
     Cube3D.Initilize(this.graphics.GraphicsDevice);
     AlienwareFXManager.Init();
     this.graphics.GraphicsDevice.DeviceLost += new EventHandler <EventArgs>(this.GraphicsDevice_DeviceLost);
     base.Initialize();
 }
コード例 #3
0
        public void doTabComplete()
        {
            List <string> stringList1 = new List <string>();

            if (this.currentLine.Length == 0)
            {
                return;
            }
            int length1 = this.currentLine.IndexOf(' ');

            if (length1 >= 1)
            {
                string path = this.currentLine.Substring(length1 + 1);
                string str1 = this.currentLine.Substring(0, length1);
                if (str1.Equals("upload") || str1.Equals("up"))
                {
                    int length2 = path.LastIndexOf('/');
                    if (length2 < 0)
                    {
                        length2 = 0;
                    }
                    string str2 = path.Substring(0, length2) + "/";
                    if (str2.StartsWith("/"))
                    {
                        str2 = str2.Substring(1);
                    }
                    string str3   = path.Substring(length2 + (length2 == 0 ? 0 : 1));
                    Folder folder = Programs.getFolderAtPathAsFarAsPossible(path, this.os, this.os.thisComputer.files.root);
                    bool   flag   = false;
                    if (folder == this.os.thisComputer.files.root && str2.Length > 1)
                    {
                        flag = true;
                    }
                    if (folder == null)
                    {
                        folder = this.os.thisComputer.files.root;
                    }
                    if (!flag)
                    {
                        for (int index = 0; index < folder.folders.Count; ++index)
                        {
                            if (folder.folders[index].name.ToLower().StartsWith(str3.ToLower(), StringComparison.InvariantCultureIgnoreCase))
                            {
                                stringList1.Add(str1 + " " + str2 + folder.folders[index].name + "/");
                            }
                        }
                        for (int index = 0; index < folder.files.Count; ++index)
                        {
                            if (folder.files[index].name.ToLower().StartsWith(str3.ToLower()))
                            {
                                stringList1.Add(str1 + " " + str2 + folder.files[index].name);
                            }
                        }
                    }
                }
                else
                {
                    if (path == null || (path.Equals("") || path.Length < 1) && !str1.Equals("exe"))
                    {
                        return;
                    }
                    Folder currentFolder = Programs.getCurrentFolder(this.os);
                    for (int index = 0; index < currentFolder.folders.Count; ++index)
                    {
                        if (currentFolder.folders[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                        {
                            stringList1.Add(str1 + " " + currentFolder.folders[index].name + "/");
                        }
                    }
                    for (int index = 0; index < currentFolder.files.Count; ++index)
                    {
                        if (currentFolder.files[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                        {
                            stringList1.Add(str1 + " " + currentFolder.files[index].name);
                        }
                    }
                    if (stringList1.Count == 0)
                    {
                        for (int index = 0; index < currentFolder.files.Count; ++index)
                        {
                            if (currentFolder.files[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                            {
                                stringList1.Add(str1 + " " + currentFolder.files[index].name);
                            }
                        }
                    }
                }
            }
            else
            {
                List <string> stringList2 = new List <string>();
                stringList2.AddRange((IEnumerable <string>)ProgramList.programs);
                stringList2.AddRange((IEnumerable <string>)ProgramList.getExeList(this.os));
                for (int index = 0; index < stringList2.Count; ++index)
                {
                    if (stringList2[index].ToLower().StartsWith(this.currentLine.ToLower()))
                    {
                        stringList1.Add(stringList2[index]);
                    }
                }
            }
            if (stringList1.Count == 1)
            {
                this.currentLine = stringList1[0];
                TextBox.moveCursorToEnd(this.currentLine);
            }
            else
            {
                if (stringList1.Count <= 1)
                {
                    return;
                }
                this.os.write(this.prompt + this.currentLine);
                string str = stringList1[0];
                for (int index = 0; index < stringList1.Count; ++index)
                {
                    this.os.write(stringList1[index]);
                    for (int length2 = 0; length2 < str.Length; ++length2)
                    {
                        if (stringList1[index].Length <= length2 || (int)string.Concat((object)str[length2]).ToLowerInvariant()[0] != (int)string.Concat((object)stringList1[index][length2]).ToLowerInvariant()[0])
                        {
                            str = str.Substring(0, length2);
                            break;
                        }
                    }
                    this.currentLine = str;
                    TextBox.moveCursorToEnd(this.currentLine);
                }
            }
        }
コード例 #4
0
ファイル: Terminal.cs プロジェクト: strangea/OpenHacknet
        public void doTabComplete()
        {
            var list1 = new List <string>();

            if (currentLine.Length == 0)
            {
                return;
            }
            var length1 = currentLine.IndexOf(' ');

            if (length1 >= 1)
            {
                var path = currentLine.Substring(length1 + 1);
                var str1 = currentLine.Substring(0, length1);
                if (path == null || (path.Equals("") || path.Length < 1) && !str1.Equals("exe"))
                {
                    return;
                }
                if (str1.Equals("upload") || str1.Equals("up"))
                {
                    var length2 = path.LastIndexOf('/');
                    if (length2 < 0)
                    {
                        length2 = 0;
                    }
                    var str2 = path.Substring(0, length2) + "/";
                    if (str2.StartsWith("/"))
                    {
                        str2 = str2.Substring(1);
                    }
                    var str3   = path.Substring(length2 + (length2 == 0 ? 0 : 1));
                    var folder = Programs.getFolderAtPathAsFarAsPossible(path, os, os.thisComputer.files.root) ??
                                 os.thisComputer.files.root;
                    for (var index = 0; index < folder.folders.Count; ++index)
                    {
                        if (folder.folders[index].name.StartsWith(str3, StringComparison.InvariantCultureIgnoreCase))
                        {
                            list1.Add(str1 + " " + str2 + folder.folders[index].name + "/");
                        }
                    }
                    for (var index = 0; index < folder.files.Count; ++index)
                    {
                        if (folder.files[index].name.StartsWith(str3))
                        {
                            list1.Add(str1 + " " + str2 + folder.files[index].name);
                        }
                    }
                }
                else
                {
                    var currentFolder = Programs.getCurrentFolder(os);
                    for (var index = 0; index < currentFolder.folders.Count; ++index)
                    {
                        if (currentFolder.folders[index].name.StartsWith(path,
                                                                         StringComparison.InvariantCultureIgnoreCase))
                        {
                            list1.Add(str1 + " " + currentFolder.folders[index].name + "/");
                        }
                    }
                    for (var index = 0; index < currentFolder.files.Count; ++index)
                    {
                        if (currentFolder.files[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                        {
                            list1.Add(str1 + " " + currentFolder.files[index].name);
                        }
                    }
                    if (list1.Count == 0)
                    {
                        for (var index = 0; index < currentFolder.files.Count; ++index)
                        {
                            if (currentFolder.files[index].name.StartsWith(path,
                                                                           StringComparison.InvariantCultureIgnoreCase))
                            {
                                list1.Add(str1 + " " + currentFolder.files[index].name);
                            }
                        }
                    }
                }
            }
            else
            {
                var list2 = new List <string>();
                list2.AddRange(ProgramList.programs);
                list2.AddRange(ProgramList.getExeList(os));
                for (var index = 0; index < list2.Count; ++index)
                {
                    if (list2[index].ToLower().StartsWith(currentLine.ToLower()))
                    {
                        list1.Add(list2[index]);
                    }
                }
            }
            if (list1.Count == 1)
            {
                currentLine = list1[0];
                TextBox.moveCursorToEnd(currentLine);
            }
            else
            {
                if (list1.Count <= 1)
                {
                    return;
                }
                os.write(prompt + currentLine);
                var str = list1[0];
                for (var index = 0; index < list1.Count; ++index)
                {
                    os.write(list1[index]);
                    for (var length2 = 0; length2 < str.Length; ++length2)
                    {
                        if (list1[index].Length <= length2 || str[length2] != list1[index][length2])
                        {
                            str = str.Substring(0, length2);
                            break;
                        }
                    }
                    currentLine = str;
                    TextBox.moveCursorToEnd(currentLine);
                }
            }
        }