Example #1
0
        public ToolbarControl(ScreenComponent screenManager)
            : base(screenManager)
        {
            Player       = screenManager.Player;
            toolTextures = new Dictionary <string, Texture2D>();

            // toolTextures = new Texture2D[Player.Tools.Length];
            // int index = 0;
            foreach (var item in DefinitionManager.GetItemDefinitions())
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    System.Drawing.Bitmap bitmap = item.Icon;
                    bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    stream.Seek(0, SeekOrigin.Begin);

                    toolTextures.Add(item.GetType().FullName, Texture2D.FromStream(ScreenManager.GraphicsDevice, stream));
                }
            }
        }
Example #2
0
        protected override void OnDrawContent(SpriteBatch batch, Rectangle contentArea, GameTime gameTime, float alpha)
        {
            if (!Visible || !Enabled)
            {
                return;
            }

            //Calculate FPS
            framecount++;
            seconds += gameTime.ElapsedGameTime.TotalSeconds;
            if (framecount == 10)
            {
                lastfps    = seconds / framecount;
                framecount = 0;
                seconds    = 0;
            }

            framebuffer[bufferindex++] = (float)gameTime.ElapsedGameTime.TotalSeconds;
            bufferindex %= buffersize;

            //Draw Control Info
            controlInfo.Text = Languages.OctoClient.ActiveControls + ": " + ScreenManager.ActiveScreen.Controls.Count;

            //Draw Position
            string pos = "pos: " + Player.ActorHost.Position.ToString();

            position.Text = pos;

            //Draw Rotation
            float  grad = (Player.ActorHost.Angle / MathHelper.TwoPi) * 360;
            string rot  = "rot: " +
                          (((Player.ActorHost.Angle / MathHelper.TwoPi) * 360) % 360).ToString("0.00") + " / " +
                          ((Player.ActorHost.Tilt / MathHelper.TwoPi) * 360).ToString("0.00");

            rotation.Text = rot;

            //Draw Fps
            string fpsString = "fps: " + (1f / lastfps).ToString("0.00");

            fps.Text = fpsString;

            //Draw Loaded Chunks
            loadedChunks.Text = Languages.OctoClient.LoadedChunks + ": " + resMan.GlobalChunkCache.LoadedChunks;

            //Get Number of Loaded Items/Blocks
            loadedInfo.Text = "" + (DefinitionManager.GetItemDefinitions() as IList <IItemDefinition>).Count + " " + Languages.OctoClient.Items + " - " +
                              (DefinitionManager.GetBlockDefinitions() as IList <IItemDefinition>).Count + " " + Languages.OctoClient.Blocks;

            //Additional Play Information

            //Active Tool
            if (Player.ActorHost.ActiveTool != null)
            {
                activeTool.Text = Languages.OctoClient.ActiveItemTool + ": " + Player.ActorHost.ActiveTool.Definition.Name;
            }

            //Fly Info
            if (Player.ActorHost.Player.FlyMode)
            {
                flyInfo.Text = Languages.OctoClient.FlymodeEnabled;
            }
            else
            {
                flyInfo.Text = "";
            }

            //Draw Box Information
            if (Player.SelectedBox.HasValue)
            {
                string selection = "box: " +
                                   Player.SelectedBox.Value.ToString() + " on " +
                                   Player.SelectedSide.ToString() + " (" +
                                   Player.SelectedPoint.Value.X.ToString("0.00") + "/" +
                                   Player.SelectedPoint.Value.Y.ToString("0.00") + ") -> " +
                                   Player.SelectedEdge.ToString() + " -> " + Player.SelectedCorner.ToString();
                box.Text = selection;
            }
            else
            {
                box.Text = "";
            }
        }