Ejemplo n.º 1
0
        private void LoadMapList()
        {
            DirectoryInfo[] dirs = new DirectoryInfo(NarivianClass.MapsDirectory).GetDirectories();
            internalNames = new string[dirs.Length];

            cmbMap.Items.Clear();

            int k = 0;

            for (int i = 0; i < dirs.Length; i++)
            {
                if (File.Exists(NarivianClass.MapsDirectory + dirs[i] + "\\World.XML"))
                {
                    XmlDocument xml = new XmlDocument();
                    xml.Load(NarivianClass.MapsDirectory + dirs[i] + "\\World.XML");
                    string displayName = xml.SelectSingleNode("World/DisplayName").InnerText;
                    string version     = xml.SelectSingleNode("World/GameVersion").InnerText;

                    if (VersionChecker.CompareVersions(Application.ProductVersion.ToString(), version) >= 0)
                    {
                        cmbMap.Items.Add(displayName);
                        internalNames[k] = dirs[k].Name;
                        k += 1;
                    }
                    else
                    {
                        Log.WriteLine("Map '" + displayName + "' cannot be used because it has a GameVersion of " + version);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void PopulateList()
        {
            try
            {
                string[,] ss = new string[500, 500];
                int rows = 0, cols = 0;

                using (WebClient wc = new WebClient())
                {
                    string[] sheet = wc.DownloadString("https://docs.google.com/spreadsheet/pub?key=0Am6tel9lYl4ydDEyZUhyYUtNYmFGY2MtODIxUHFxcUE&output=txt").Split('\n');
                    rows = sheet.Length;

                    for (int i = 0; i < rows; i++)
                    {
                        string[] col = sheet[i].Split('\t');

                        for (int j = 0; j < col.Length; j++)
                        {
                            ss[i, j] = col[j];
                        }

                        if (col.Length > cols)
                        {
                            cols = col.Length;
                        }
                    }
                }

                maps = 0;
                for (int i = 1; i < rows; i++)
                {
                    if (ss[i, 0] != string.Empty)
                    {
                        MapListItem mli = new MapListItem(ss[i, 0], ss[i, 1], ss[i, 2], ss[i, 3], ss[i, 4]);

                        mli.Width    = pnlMaps.Width - 30;
                        mli.Location = new Point(0, maps * mli.Height + maps);
                        mli.Click   += mli_Click;

                        if (Directory.Exists(NarivianClass.MapsDirectory + mli.MapInternalName))
                        {
                            mli.Installed = true;

                            XmlDocument xml = new XmlDocument();
                            xml.Load(NarivianClass.MapsDirectory + mli.MapInternalName + "\\World.XML");

                            string version = xml.SelectSingleNode("World/MapVersion").InnerText;

                            if (VersionChecker.CompareVersions(version, mli.MapVersion) >= 0)
                            {
                                mli.UpToDate = true;
                            }
                            else
                            {
                                mli.UpToDate = false;
                            }
                        }
                        else
                        {
                            mli.Installed = false;
                            mli.UpToDate  = false;
                        }

                        pnlMaps.Controls.Add(mli);
                        maps += 1;
                    }
                }
            }
            catch
            {
                Notice.Show("Cannot access maps database\n\nPlease check your internet connection", "Error", "GameVersion");
            }
        }