コード例 #1
0
ファイル: StatisticTracker.cs プロジェクト: xoxota99/Myre
 public StatisticTracker(Statistic statistic, TimeSpan accessInterval)
 {
     _stat = statistic;
     _accessInterval = accessInterval;
     _lastAccess = DateTime.Now;
     _lastValue = statistic.Value;
 }
コード例 #2
0
ファイル: StatisticGraph.cs プロジェクト: xoxota99/Myre
        public StatisticGraph(Control parent, SpriteFont font, Statistic statistic, TimeSpan accessInterval)
            : base(parent)
        {
            if (statistic == null)
                throw new ArgumentNullException("statistic");

            if (accessInterval == TimeSpan.Zero)
                accessInterval = TimeSpan.FromMilliseconds(16);

            Strata = new ControlStrata() { Layer = Layer.Overlay };
            _tracker = new StatisticTracker(statistic, accessInterval);
            _graph = new Graph(Device, (int)(15f / (float)accessInterval.TotalSeconds)); //(byte)MathHelper.Clamp(15f / (float)accessInterval.TotalSeconds, 15, 15 * 60));
            _label = new Label(this, font) {
                Text = statistic.Name,
                Justification = Justification.Centre
            };
            _label.SetPoint(Points.TopLeft, 2, 2);
            _label.SetPoint(Points.TopRight, -2, 2);

            _value = new Label(this, font) {
                Text = "0",
                Justification = Justification.Centre
            };
            _value.SetPoint(Points.BottomLeft, 2, -2);
            _value.SetPoint(Points.BottomRight, -2, -2);

            _texture = new Texture2D(Device, 1, 1);
            _texture.SetData<Color>(new Color[] { new Color(0, 0, 0, 0.8f) });

            SetSize(200, 120);
        }
コード例 #3
0
ファイル: StatisticTextLog.cs プロジェクト: ylyking/Myre
 /// <summary>
 /// Adds the statistic.
 /// </summary>
 /// <param name="statistic">The statistic.</param>
 /// <param name="accessInterval">The time between readings of the statistic.</param>
 public void AddStatistic(Statistic statistic, TimeSpan accessInterval)
 {
     if (statistic == null)
         throw new ArgumentNullException("statistic");
     if (!_stats.ContainsKey(statistic.Name))
         _stats.Add(statistic.Name, new StatisticText(this, statistic, accessInterval, _font));
     UpdatePositions();
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FrequencyTracker"/> class.
 /// </summary>
 /// <param name="statisticName">Name of the statistic.</param>
 public FrequencyTracker(string statisticName)
 {
     lastUpdate = DateTime.Now;
     if (!string.IsNullOrEmpty(statisticName))
         statistic = Statistic.Get(statisticName);
 }
コード例 #5
0
 public StatisticText(StatisticTextLog log, Statistic statistic, TimeSpan accessInterval, SpriteFont font)
     : base(statistic, accessInterval)
 {
     label = new Label(log, font);
     label.Text = statistic.Name + ": " + string.Format(statistic.Format, statistic.Value);
 }
コード例 #6
0
 /// <summary>
 /// Removes the statistic from the log.
 /// </summary>
 /// <param name="statistic">The statistic.</param>
 public void RemoveStatistic(Statistic statistic)
 {
     if (stats.ContainsKey(statistic.Name) && stats[statistic.Name].Statistic == statistic)
     {
         //Remove(stats[statistic.Name].Label);
         stats[statistic.Name].Label.Dispose();
         stats.Remove(statistic.Name);
         UpdatePositions();
     }
 }
コード例 #7
0
ファイル: Statistic.cs プロジェクト: Quantumplation/Myre
        /// <summary>
        /// Gets the statistic.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static Statistic Get(string name, string format = null)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");

            Statistic stat;
            if (!statistics.TryGetValue(name, out stat))
            {
                stat = new Statistic(name);
                statistics[name] = stat;
            }

            stat.Format = format ?? stat.Format ?? "{0}";
            return stat;
        }
コード例 #8
0
ファイル: TestGame.cs プロジェクト: martindevans/Myre
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            _ui = new UserInterface(GraphicsDevice);

            Player = new InputActor(1, new MouseDevice(), new KeyboardDevice(PlayerIndex.One, Window.Handle));
            //Kernel.Bind<InputActor>().ToConstant(player);
            Components.Add(Player);
            _ui.Actors.Add(Player);

            var statLog = new StatisticTextLog(_ui.Root, Content.Load<SpriteFont>("Consolas"), true);
            statLog.SetPoint(Points.TopLeft, 10, 10);

            _frameTime = Statistic.Create("Misc.Time", "{0:00.00}ms");
            _fps = new FrequencyTracker("Misc.FPS");

            var console = new CommandConsole(this, Content.Load<SpriteFont>("Consolas"), _ui.Root);
            Kernel.Bind<CommandConsole>().ToConstant(console);

            _screens = new ScreenManager();
            _screens.Push(Kernel.Get<MainMenu>());

            base.Initialize();
        }
コード例 #9
0
ファイル: StatisticGraph.cs プロジェクト: sachgits/Myre
 public StatisticGraph(Control parent, SpriteFont font, string statisticName, TimeSpan accessInterval)
     : this(parent, font, Statistic.Get(statisticName), accessInterval)
 {
 }
コード例 #10
0
 /// <summary>
 /// Adds the statistic to the log.
 /// </summary>
 /// <param name="statisticName">Name of the statistic.</param>
 /// <param name="accessInterval">The time between readings of the statistic.</param>
 public void AddStatistic(string statisticName, TimeSpan accessInterval)
 {
     AddStatistic(Statistic.Get(statisticName), accessInterval);
 }
コード例 #11
0
 public StatisticText(StatisticTextLog log, Statistic statistic, TimeSpan accessInterval, SpriteFont font)
     : base(statistic, accessInterval)
 {
     label      = new Label(log, font);
     label.Text = statistic.Name + ": " + string.Format(statistic.Format, statistic.Value);
 }