Пример #1
0
        public LibraryView(SteamData steamData, SteamLibrary library)
        {
            InitializeComponent();

            SteamData = steamData;
            Library   = library;

            SteamData.ChangesDiscarded        += SteamData_ChangesDiscarded;
            SteamData.AppTargetLibraryChanged += SteamApp_TargetLibraryChanged;
            SteamData.AppMoved += SteamApp_Moved;

            // Init labels.
            UpdateHeader();

            // Init grid
            gridViewItems = new BindingList <GridViewItem>();

            dataGrid.DataSource = gridViewItems;
            dataGrid.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGrid.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dataGrid.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGrid.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            UpdateAppList();
        }
Пример #2
0
 private void btnScan_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     dataSet.Clear();
     Steam.RootPath = FindSteamPath();
     Steam.Scan();
     SteamData.Save(AppDataPath + "data.xml");
 }
Пример #3
0
 public static void LoadUserAccts()
 {
     if (DataStorage.SaveExists(accountFile))
     {
         accounts = SteamData.Load(accountFile).ToList();
     }
     else
     {
         accounts = new List <SteamAccount>();
         SaveAccounts();
     }
 }
Пример #4
0
        private void Main_Shown(object sender, EventArgs e)
        {
            if (!SteamData.Load(AppDataPath + "data.xml"))
            {
                btnScan_LinkClicked(null, null);
            }
            userBox.DataSource = dataSet.Tables["Users"];
            gameBox.DataSource = dataSet.Tables["UserGame"];

            userBox.SelectedText            = Settings.Element("LastUser")?.Value;
            checkShowAll.Checked            = Convert.ToBoolean(Settings.Element("ShowAllApp")?.Value);
            gameBox.SelectedText            = Settings.Element("LastGame")?.Value;
            addImageDialog.InitialDirectory = Settings.Element("LastFileDialogPath")?.Value;
            addFolderDialog.SelectedPath    = Settings.Element("LastFolderDialogPath")?.Value;
        }
 void LoadAddonList()
 {
     AddOns = new ObservableCollection <string>(SteamData.GetAddOnList());
 }
Пример #6
0
        public static CsgoLastMatch GetCSGOLastMatch(SocketUser user, ulong SteamID)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.csgoURL + SteamID);

            request.ContentType = "application/json; charset=utf-8";
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            string          data     = "";

            using (Stream responseStream = response.GetResponseStream())
            {
                StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                data = reader.ReadToEnd();
            }

            Dictionary <string, PlayerStats> r = JsonConvert.DeserializeObject <Dictionary <string, PlayerStats> >(data);
            string      msg   = "";
            PlayerStats stats = r["playerstats"];

            string[] wantedStats = { "last_match_rounds",          "last_match_contribution_score", "last_match_wins",   "last_match_t_wins",      "last_match_ct_wins",     "last_match_kills",
                                     "last_match_deaths",          "last_match_mvps",               "last_match_damage", "last_match_money_spent", "last_match_dominations", "last_match_revenges","last_match_favweapon_id",
                                     "last_match_favweapon_shots", "last_match_favweapon_hits",     "last_match_favweapon_kills" };

            string[] formattedStats = { "Rounds",                "Contribution Score",   "Wins",   "Terrorist Wins", "Counter-Terrorist Wins", "Kills",
                                        "Deaths",                "MVPs",                 "Damage", "Money Spent",    "Dominations",            "Revenges","Favorite Weapon",
                                        "Favorite Weapon Shots", "Favorite Weapon Hits", "Favorite Weapon Kills" };

            int           max            = stats.stats.Count - 1;
            float         kills          = 0;
            float         deaths         = 0;
            float         KD             = 0;
            float         shots          = 0;
            float         hits           = 0;
            float         accuracy       = 0;
            float         rounds         = 0;
            SteamAccount  steamaccount   = GetAccount(user);
            CsgoLastMatch lastmatch      = new CsgoLastMatch();
            bool          createNewMatch = false;

            if (steamaccount != null)
            {
                if (steamaccount.SteamID == SteamID && steamaccount.DiscordID == user.Id)
                {
                    createNewMatch = true;
                }
            }

            for (int x = 0; x < wantedStats.Length; x++)
            {
                for (int i = 0; i < stats.stats.Count; i++)
                {
                    Stats curStat = stats.stats[i];
                    if (wantedStats[x] == curStat.name)
                    {
                        string value = curStat.value.ToString();
                        string name  = formattedStats[x];

                        if (name == "Revenges")
                        {
                            lastmatch.revenges = (uint)curStat.value;
                        }
                        if (name == "Dominations")
                        {
                            lastmatch.dominations = (uint)curStat.value;
                        }
                        if (name == "Damage")
                        {
                            lastmatch.damage = (uint)curStat.value;
                        }
                        if (name == "MVPs")
                        {
                            lastmatch.mvps = (uint)curStat.value;
                        }
                        if (name == "Contribution Score")
                        {
                            lastmatch.contribution_score = (uint)curStat.value;
                        }
                        if (name == "Terrorist Wins")
                        {
                            lastmatch.t_wins = (uint)curStat.value;
                        }
                        if (name == "Counter-Terrorist Wins")
                        {
                            lastmatch.ct_wins = (uint)curStat.value;
                        }

                        if (name == "Rounds")
                        {
                            rounds           = curStat.value;
                            lastmatch.rounds = (uint)curStat.value;
                        }

                        if (name == "Wins")
                        {
                            lastmatch.losses = uint.Parse((rounds - curStat.value) + "");
                            name             = "Game Outcome";
                            if (curStat.value > lastmatch.losses)
                            {
                                value = "Won";
                            }
                            else if (curStat.value == lastmatch.losses)
                            {
                                value = "Draw";
                            }
                            else
                            {
                                value = "Lost";
                            }

                            lastmatch.wins    = (uint)curStat.value;
                            lastmatch.outcome = value;
                            //Console.WriteLine("Rounds Won:" + curStat.value);
                        }
                        if (name == "Money Spent")
                        {
                            value = string.Format("${0:N2}", float.Parse(value));
                            lastmatch.money_spent = (uint)curStat.value;
                        }

                        if (name == "Kills")
                        {
                            kills           = float.Parse(value);
                            lastmatch.kills = (uint)curStat.value;
                        }

                        if (name == "Favorite Weapon Kills")
                        {
                            lastmatch.favweapon_kills = (uint)curStat.value;
                        }
                        if (name == "Favorite Weapon Shots")
                        {
                            shots = curStat.value;
                            lastmatch.favweapon_shots = (uint)curStat.value;
                        }
                        if (name == "Favorite Weapon")
                        {
                            value = getGunName(int.Parse(value));
                            lastmatch.favweapon_name = value;
                        }
                        msg += "**" + name + "**: " + value + "\n";
                        if (name == "Deaths")
                        {
                            deaths           = float.Parse(value);
                            KD               = kills / deaths;
                            msg             += "**K/D Ratio**: " + string.Format("{0:N2}", KD) + "\n";
                            lastmatch.deaths = (uint)curStat.value;
                            lastmatch.kd     = KD;
                        }
                        if (name == "Favorite Weapon Hits")
                        {
                            hits     = curStat.value;
                            accuracy = hits / shots * 100f;
                            msg     += string.Format("**Favorite Weapon Accuracy:** {0:N2}%\n", accuracy);
                            lastmatch.favweapon_hits = (uint)curStat.value;
                            lastmatch.accuracy       = accuracy;
                        }
                    }
                }
            }
            if (createNewMatch)
            {
                CsgoLastMatches matches = new CsgoLastMatches();
                matches.steamid   = SteamID;
                matches.discordid = user.Id;
                matches.username  = user.Username;
                if (matches.lastmatches == null)
                {
                    matches.lastmatches = new List <CsgoLastMatch>();
                }
                for (int i = 0; i < SteamData.matches.Count; i++)
                {
                    while (SteamData.matches[i].lastmatches.Count > 10)
                    {
                        SteamData.matches[i].lastmatches.RemoveAt(0);
                    }
                }
                lastmatch.createID();
                matches.lastmatches.Add(lastmatch);
                SteamData.AddLastMatchesToStorage(matches);
                Console.WriteLine("Created new match and Saved to User: " + user.Username);
            }
            //Console.WriteLine(msg);
            return(lastmatch);
        }
Пример #7
0
 public static void SaveAccounts()
 {
     SteamData.Save(accounts, accountFile);
 }
Пример #8
0
        private static IModinfo MergeFrom(IModinfo current, IModinfo target)
        {
            var name = target.Name;

            var summary = current.Summary;

            if (!string.IsNullOrEmpty(target.Summary))
            {
                summary = target.Summary;
            }

            var icon = current.Icon;

            if (!string.IsNullOrEmpty(target.Icon))
            {
                icon = target.Icon;
            }

            var version = current.Version;

            if (target.Version != null)
            {
                version = target.Version;
            }

            var custom = current.Custom;

            if (target.Custom.Any())
            {
                foreach (var customObject in target.Custom)
                {
                    if (custom.Contains(customObject))
                    {
                        continue;
                    }
                    custom.Add(customObject);
                }
            }

            var steamData = current.SteamData;

            if (target.SteamData != null)
            {
                steamData = new SteamData(target.SteamData);
            }

            var dependencies = current.Dependencies;

            if (target.Dependencies.Any())
            {
                dependencies = new DependencyList(target.Dependencies);
            }

            var languages = current.Languages;

            if (target.Languages.Any())
            {
#if NETSTANDARD2_1
                languages = target.Languages.Select(x => (ILanguageInfo) new LanguageInfo(x)).ToHashSet(null);
#else
                languages = target.Languages.Select(x => (ILanguageInfo) new LanguageInfo(x)).Distinct();
#endif
            }

            return(new ModinfoData(name)
            {
                Custom = custom,
                SteamData = steamData,
                Summary = summary,
                Dependencies = dependencies,
                Icon = icon,
                Languages = languages,
                Version = version
            });
        }
Пример #9
0
 private void SteamData_ChangesDiscarded(SteamData data)
 {
     UpdateAppList();
 }