Beispiel #1
0
        public void RefreshMaps()
        {
            Tree.Nodes.Clear();
            _TreeCache.Nodes.Clear();
            string mapdir = GlobalPaths.MapsDir;

            string[] fileexts = new string[] { ".rbxl", ".rbxlx" };
            TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
            TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
            Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
            Tree.Focus();
            if (File.Exists(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt"))
            {
                MapDescBox.Text = File.ReadAllText(GlobalPaths.RootPath + @"\\" + Tree.SelectedNode.FullPath.ToString().Replace(".rbxl", "").Replace(".rbxlx", "") + "_desc.txt");
            }
            else
            {
                MapDescBox.Text = Tree.SelectedNode.Text.ToString();
            }
        }
Beispiel #2
0
        public async Task ChangeTabs()
        {
            switch (Tabs.SelectedTab)
            {
            case TabPage pg2 when pg2 == Tabs.TabPages[TabPageHost]:
                Tree.Nodes.Clear();
                _TreeCache.Nodes.Clear();
                MapDescBox.Text = "";
                ClientBox.Items.Clear();
                ServerBox.Items.Clear();
                PortBox.Items.Clear();
                //since we are async, DO THESE first or we'll clear out random stuff.
                ServerInfo.Text = "Loading...";
                string IP = await SecurityFuncs.GetExternalIPAddressAsync();

                ServerInfo.Text = "";
                string[] lines1 =
                {
                    SecurityFuncs.Base64Encode((!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP)),
                    SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
                    SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
                };
                string   URI    = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines1), true);
                string[] lines2 =
                {
                    SecurityFuncs.Base64Encode("localhost"),
                    SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
                    SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
                };
                string   URI2 = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines2), true);
                string[] text =
                {
                    "Client: " + GlobalVars.UserConfiguration.SelectedClient,
                    "IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : IP),
                    "Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(),
                    "Map: " + GlobalVars.UserConfiguration.Map,
                    "Players: " + GlobalVars.UserConfiguration.PlayerLimit,
                    "Version: Novetus " + GlobalVars.ProgramInformation.Version,
                    "Online URI Link:",
                    URI,
                    "Local URI Link:",
                    URI2
                };

                foreach (string str in text)
                {
                    if (!string.IsNullOrWhiteSpace(str))
                    {
                        ServerInfo.AppendText(str + Environment.NewLine);
                    }
                }
                ServerInfo.SelectionStart = 0;
                ServerInfo.ScrollToCaret();
                break;

            case TabPage pg3 when pg3 == Tabs.TabPages[TabPageClients]:
                string          clientdir = GlobalPaths.ClientDir;
                DirectoryInfo   dinfo     = new DirectoryInfo(clientdir);
                DirectoryInfo[] Dirs      = dinfo.GetDirectories();
                foreach (DirectoryInfo dir in Dirs)
                {
                    ClientBox.Items.Add(dir.Name);
                }
                ClientBox.SelectedItem = GlobalVars.UserConfiguration.SelectedClient;
                Tree.Nodes.Clear();
                _TreeCache.Nodes.Clear();
                MapDescBox.Text = "";
                ServerInfo.Text = "";
                ServerBox.Items.Clear();
                PortBox.Items.Clear();
                break;

            case TabPage pg4 when pg4 == Tabs.TabPages[TabPageMaps]:
                string   mapdir   = GlobalPaths.MapsDir;
                string[] fileexts = new string[] { ".rbxl", ".rbxlx" };
                TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
                TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
                Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
                Tree.Focus();
                ServerInfo.Text = "";
                ClientBox.Items.Clear();
                ServerBox.Items.Clear();
                PortBox.Items.Clear();
                break;

            case TabPage pg6 when pg6 == Tabs.TabPages[TabPageSaved]:
                string[] lines_server = File.ReadAllLines(GlobalPaths.ConfigDir + "\\servers.txt");
                string[] lines_ports  = File.ReadAllLines(GlobalPaths.ConfigDir + "\\ports.txt");
                ServerBox.Items.AddRange(lines_server);
                PortBox.Items.AddRange(lines_ports);
                Tree.Nodes.Clear();
                _TreeCache.Nodes.Clear();
                MapDescBox.Text = "";
                ServerInfo.Text = "";
                ClientBox.Items.Clear();
                break;

            default:
                Tree.Nodes.Clear();
                _TreeCache.Nodes.Clear();
                MapDescBox.Text = "";
                ServerInfo.Text = "";
                ClientBox.Items.Clear();
                ServerBox.Items.Clear();
                PortBox.Items.Clear();
                break;
            }
        }