Beispiel #1
0
        private int StoreStatistics()
        {
            if (this.Statistics.Count == 0)
            {
                return(0);
            }
            List <StatInfo> statInfoList = new List <StatInfo>();

            foreach (StatInfo statistic in (Collection <StatInfo>) this.Statistics)
            {
                if (statistic.Modified)
                {
                    statInfoList.Add(statistic);
                }
            }
            if (statInfoList.Count == 0)
            {
                return(0);
            }
            foreach (StatInfo statInfo in statInfoList)
            {
                if (statInfo is IntStatInfo)
                {
                    IntStatInfo intStatInfo = (IntStatInfo)statInfo;
                    if (!this.SteamClient.SteamUserStats.SetStatValue(intStatInfo.Id, intStatInfo.IntValue))
                    {
                        int num = (int)MessageBox.Show((IWin32Window)this, string.Format("An error occured while setting the value for {0}, aborting store.", (object)statInfo.Id), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return(-1);
                    }
                }
                else
                {
                    if (!(statInfo is FloatStatInfo))
                    {
                        throw new Exception();
                    }
                    FloatStatInfo floatStatInfo = (FloatStatInfo)statInfo;
                    if (!this.SteamClient.SteamUserStats.SetStatValue(floatStatInfo.Id, floatStatInfo.FloatValue))
                    {
                        int num = (int)MessageBox.Show((IWin32Window)this, string.Format("An error occured while setting the value for {0}, aborting store.", (object)statInfo.Id), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return(-1);
                    }
                }
            }
            return(statInfoList.Count);
        }
Beispiel #2
0
 private void GetStatistics()
 {
     this.Statistics.Clear();
     foreach (StatDefinition statDefinition in this.StatDefinitions)
     {
         if (!string.IsNullOrEmpty(statDefinition.Id))
         {
             if (statDefinition is IntegerStatDefinition)
             {
                 IntegerStatDefinition integerStatDefinition = (IntegerStatDefinition)statDefinition;
                 int num = 0;
                 if (this.SteamClient.SteamUserStats.GetStatValue(integerStatDefinition.Id, ref num))
                 {
                     BindingList <StatInfo> statistics   = this.Statistics;
                     IntStatInfo            intStatInfo1 = new IntStatInfo();
                     intStatInfo1.Id            = integerStatDefinition.Id;
                     intStatInfo1.DisplayName   = integerStatDefinition.DisplayName;
                     intStatInfo1.IntValue      = num;
                     intStatInfo1.OriginalValue = num;
                     intStatInfo1.IncrementOnly = integerStatDefinition.IncrementOnly;
                     intStatInfo1.Permission    = integerStatDefinition.Permission;
                     IntStatInfo intStatInfo2 = intStatInfo1;
                     statistics.Add((StatInfo)intStatInfo2);
                 }
             }
             else if (statDefinition is FloatStatDefinition)
             {
                 FloatStatDefinition floatStatDefinition = (FloatStatDefinition)statDefinition;
                 float num = 0.0f;
                 if (this.SteamClient.SteamUserStats.GetStatValue(floatStatDefinition.Id, ref num))
                 {
                     BindingList <StatInfo> statistics     = this.Statistics;
                     FloatStatInfo          floatStatInfo1 = new FloatStatInfo();
                     floatStatInfo1.Id            = floatStatDefinition.Id;
                     floatStatInfo1.DisplayName   = floatStatDefinition.DisplayName;
                     floatStatInfo1.FloatValue    = num;
                     floatStatInfo1.OriginalValue = num;
                     floatStatInfo1.IncrementOnly = floatStatDefinition.IncrementOnly;
                     floatStatInfo1.Permission    = floatStatDefinition.Permission;
                     FloatStatInfo floatStatInfo2 = floatStatInfo1;
                     statistics.Add((StatInfo)floatStatInfo2);
                 }
             }
         }
     }
 }