Ejemplo n.º 1
0
        public Games(string path)
        {
            List <CategoryOfAchievement> _categories = new List <CategoryOfAchievement>();

            categories = _categories;
            address    = path;
            var path2 = Path.Combine(Directory.GetCurrentDirectory() + @"\" + path);
            //if (!Directory.Exists(path2))
            //{
            //    Directory.CreateDirectory(path2);
            //    File.WriteAllText()
            //}
            DirectoryInfo d = new DirectoryInfo(path2);

            foreach (var file in d.GetFiles())
            {
                string text = File.ReadAllText(file.FullName);
                CategoryOfAchievement CoA = JsonConvert.DeserializeObject <CategoryOfAchievement>(text);
                string[] id = file.Name.Split('_');
                CoA.id = Convert.ToInt32(id[0]);
                categories.Add(CoA);
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                dataGridView1.Rows.Clear();
                dataGridView1.Refresh();
                dynamic item = comboBox2.SelectedItem;
                string  id   = item.ID;

                dynamic accountId = comboBox1.SelectedItem;
                string  idk       = accountId.ID;
                string  adres     = "http://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001/?appid=" + id + "&key=" + key.GetKey() + "&steamid=" + idk;
                using (WebClient client = new WebClient())
                {
                    string      htmlCode     = client.DownloadString(adres);
                    JsonOutAchs achievements = JsonConvert.DeserializeObject <JsonOutAchs>(htmlCode);
                    //Dictionary<int, bool> dicToRead = new Dictionary<int, bool>();
                    Dictionary <string, bool> dicToRead = new Dictionary <string, bool>();
                    int     ii  = 0;
                    dynamic cb3 = comboBox3.SelectedItem;
                    ActualCoA = ActualGame.categories[cb3.Value];
                    int achievedAchs = 0;
                    foreach (var b in achievements.playerstats.achievements)
                    {
                        if (b.achieved == 1)
                        {
                            dicToRead.Add(b.apiname, true);
                        }
                        else
                        {
                            dicToRead.Add(b.apiname, false);
                        }
                        ii++;
                    }

                    List <string> tabtmp = new List <string>();
                    foreach (string ac in ActualCoA.upName)
                    {
                        tabtmp.Add(ac);
                    }
                    //bool ayy = false;
                    tabtmp.RemoveAt(0);
                    dataGridView1.ColumnCount = tabtmp.Count;

                    dataGridView1.Rows.Add(tabtmp.ToArray());
                    int zz = 1;
                    foreach (var a in ActualCoA.maps)
                    {
                        List <string> datas = new List <string>();
                        datas.Add(a.name);

                        foreach (var c in a.id)
                        {
                            if (c == "NULL")
                            {
                                continue;
                            }

                            datas.Add(c);
                        }
                        dataGridView1.Rows.Add(datas.ToArray());
                        if (a.type == TypeMap.Long || a.type == TypeMap.Waves)
                        {
                            dataGridView1[0, zz].Style.BackColor = Color.MediumPurple;
                        }
                        else if (a.type == TypeMap.Normal)
                        {
                            dataGridView1[0, zz].Style.BackColor = Color.Orange;
                        }
                        else if (a.type == TypeMap.Objective)
                        {
                            dataGridView1[0, zz].Style.BackColor = Color.CadetBlue;
                        }
                        else
                        {
                            dataGridView1[0, zz].Style.BackColor = Color.Orange;
                        }
                        int i = 1;
                        foreach (var c in a.id)
                        {
                            if (c == "NULL")
                            {
                                dataGridView1[i, zz].Value           = "NULL";
                                dataGridView1[i, zz].Style.BackColor = Color.LightGray;
                                i++;
                                continue;
                            }

                            else if (dicToRead.ContainsKey(c))
                            {
                                if (dicToRead[c])
                                {
                                    dataGridView1[i, zz].Value           = "Done";
                                    dataGridView1[i, zz].Style.BackColor = Color.GreenYellow;
                                    achievedAchs++;
                                }
                                else
                                {
                                    dataGridView1[i, zz].Value           = "Unfinished";
                                    dataGridView1[i, zz].Style.BackColor = Color.OrangeRed;
                                }
                            }
                            else//For some reason "NULL" != "NULL"
                            {
                                dataGridView1[i, zz].Value           = "NULL";
                                dataGridView1[i, zz].Style.BackColor = Color.LightGray;
                                i++;
                                continue;
                            }
                            i++;
                        }
                        zz++;
                    }


                    label10.Text = achievedAchs + " / " + ActualCoA.maps.Count * (ActualCoA.upName.Count - 2) + " achievements.\n" + Math.Floor(100 * (float)((float)achievedAchs / ((float)ActualCoA.maps.Count * (float)(ActualCoA.upName.Count - 2)))) + "% Done";
                    dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
            }


            catch (Exception)
            {
                MessageBox.Show("Missing key in key.txt, Wrong ID, private profile, account doesnt have that game or private games list (patch from 11.04.2018)", "Error");
            }
        }