public MainForm()
        {
            palette = Palette.VGA;
            InitializeComponent();

            ColorSelector_Update();


            this.statusMode.Text = drawMode.ToString();
            FullRedraw();
            UpdateStackButtons();
        }
Exemple #2
0
 public void GltfSerialize(JsonWriter writer)
 {
     writer.AddObject();
     if (attributes != null)
     {
         writer.AddProperty("attributes");
         attributes.GltfSerialize(writer);
     }
     if (indices >= 0)
     {
         writer.AddProperty("indices", indices);
     }
     if (material >= 0)
     {
         writer.AddProperty("material", material);
     }
     if (mode != DrawMode.Triangles)
     {
         writer.AddProperty("mode", mode.ToString());
     }
     if (targets != null)
     {
         writer.AddArray("targets");
         foreach (var target in targets)
         {
             target.GltfSerialize(writer);
         }
         writer.CloseArray();
     }
     if (extensions != null)
     {
         extensions.GltfSerialize(writer);
     }
     writer.Close();
 }
Exemple #3
0
        void Draw( Player player, Command command, DrawMode mode ) {
            if( !player.Can( Permissions.Draw ) ) {
                world.NoAccessMessage( player );
                return;
            }
            if( player.drawingInProgress ) {
                player.Message( "Another draw command is already in progress. Please wait." );
                return;
            }
            string blockName = command.Next();
            Block block;
            if( blockName == null || blockName == "" ) {
                if( mode == DrawMode.Cuboid ) {
                    player.Message( "Usage: " + Color.Help + "/cuboid blockName" + Color.Sys + " or " + Color.Help + "/cub blockName" );
                } else {
                    player.Message( "Usage: " + Color.Help + "/ellipsoid blockName" + Color.Sys + " or " + Color.Help + "/ell blockName" );
                }
                return;
            }
            try {
                block = Map.GetBlockByName( blockName );
            } catch( Exception ) {
                player.Message( "Unknown block name: " + blockName );
                return;
            }
            player.tag = block;

            Permissions permission = Permissions.Build;
            switch( block ) {
                case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;
                case Block.Air: permission = Permissions.Delete; break;
                case Block.Water:
                case Block.StillWater: permission = Permissions.PlaceWater; break;
                case Block.Lava:
                case Block.StillLava: permission = Permissions.PlaceLava; break;
            }
            if( !player.Can( permission ) ) {
                player.Message( "You are not allowed to draw with this block." );
                return;
            }

            player.marksExpected = 2;
            player.markCount = 0;
            player.marks.Clear();
            player.Message( mode.ToString() + ": Place a block or type /mark to use your location." );

            if( mode == DrawMode.Cuboid ) {
                player.selectionCallback = DrawCuboid;
            } else {
                player.selectionCallback = DrawEllipsoid;
            }
        }
        private void добавитьТекстToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (var el in menuEdit.DropDownItems)
            {
                if (!(el is ToolStripMenuItem))
                {
                    continue;
                }
                (el as ToolStripMenuItem).Checked = false;
            }

            if (!(sender is ToolStripMenuItem))
            {
                return;
            }
            ToolStripMenuItem toolSelector = (ToolStripMenuItem)sender;

            drawMode             = (DrawMode)Enum.Parse(drawMode.GetType(), toolSelector.Tag as string);
            toolSelector.Checked = true;
            statusMode.Text      = drawMode.ToString();
        }
Exemple #5
0
        void Draw(Player player, Command command, DrawMode mode)
        {
            if (!player.Can(Permissions.Draw))
            {
                world.NoAccessMessage(player);
                return;
            }
            if (player.drawingInProgress)
            {
                player.Message("Another draw command is already in progress. Please wait.");
                return;
            }
            string blockName = command.Next();
            Block  block;

            if (blockName == null || blockName == "")
            {
                if (mode == DrawMode.Cuboid)
                {
                    player.Message("Usage: " + Color.Help + "/cuboid blockName" + Color.Sys + " or " + Color.Help + "/cub blockName");
                }
                else
                {
                    player.Message("Usage: " + Color.Help + "/ellipsoid blockName" + Color.Sys + " or " + Color.Help + "/ell blockName");
                }
                return;
            }
            try {
                block = Map.GetBlockByName(blockName);
            } catch (Exception) {
                player.Message("Unknown block name: " + blockName);
                return;
            }
            player.tag = block;

            Permissions permission = Permissions.Build;

            switch (block)
            {
            case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;

            case Block.Air: permission = Permissions.Delete; break;

            case Block.Water:
            case Block.StillWater: permission = Permissions.PlaceWater; break;

            case Block.Lava:
            case Block.StillLava: permission = Permissions.PlaceLava; break;
            }
            if (!player.Can(permission))
            {
                player.Message("You are not allowed to draw with this block.");
                return;
            }

            player.marksExpected = 2;
            player.markCount     = 0;
            player.marks.Clear();
            player.Message(mode.ToString() + ": Place a block or type /mark to use your location.");

            if (mode == DrawMode.Cuboid)
            {
                player.selectionCallback = DrawCuboid;
            }
            else
            {
                player.selectionCallback = DrawEllipsoid;
            }
        }
        /// <summary>
        /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then
        /// the final opacity is 64)
        /// </summary>
        public void DrawBall(Ball ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;
            #region Figure out the color

            if (drawRed)
            {
                color = REDCOLOR;
            }
            else
            {
                color = Color.Gold;
            }

            #endregion

            int finalOpacity;
            #region Figure out the opacity

            switch (mode)
            {
                case DrawMode.Building:
                    finalOpacity = BUILDINGBALLFILLOPACTIY;
                    break;

                case DrawMode.Selected:
                case DrawMode.Standard:
                    finalOpacity = STANDARDBALLFILLOPACTIY;
                    break;

                default:
                    throw new ApplicationException("Unknown DrawMode: " + mode.ToString());
            }

            finalOpacity = Convert.ToInt32(finalOpacity * opacity);
            if (finalOpacity < 0)
            {
                finalOpacity = 0;
            }
            else if (finalOpacity > 255)
            {
                finalOpacity = 255;
            }

            #endregion

            // Collision Style
            DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle);

            // Fill the circle
            using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color)))
            {
                _viewer.FillCircle(brush, ball.Position, ball.Radius);
            }

            #region Draw the edge

            switch (mode)
            {
                case DrawMode.Building:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Standard:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Selected:
                    _viewer.DrawCircle_Selected(ball.Position, ball.Radius);
                    break;
            }

            #endregion

            //TODO:  Show Stats
        }
        /// <summary>
        /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then
        /// the final opacity is 64)
        /// </summary>
        public void DrawSolidBall(SolidBall ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;
            #region Figure out the color

            if (drawRed)
            {
                color = REDCOLOR;
            }
            else
            {
                color = Color.RoyalBlue;
            }

            #endregion

            int finalOpacity;
            #region Figure out the opacity

            switch (mode)
            {
                case DrawMode.Building:
                    finalOpacity = BUILDINGBALLFILLOPACTIY;
                    break;

                case DrawMode.Selected:
                case DrawMode.Standard:
                    finalOpacity = STANDARDBALLFILLOPACTIY;
                    break;

                default:
                    throw new ApplicationException("Unknown DrawMode: " + mode.ToString());
            }

            finalOpacity = Convert.ToInt32(finalOpacity * opacity);
            if (finalOpacity < 0)
            {
                finalOpacity = 0;
            }
            else if (finalOpacity > 255)
            {
                finalOpacity = 255;
            }

            #endregion

            MyVector dirFacing;
            #region Figure out direction facing

            dirFacing = ball.DirectionFacing.Standard.Clone();
            dirFacing.BecomeUnitVector();
            dirFacing.Multiply(ball.Radius);
            dirFacing.Add(ball.Position);

            #endregion

            // Collision Style
            DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle);

            // Fill the circle
            using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color)))
            {
                _viewer.FillCircle(brush, ball.Position, ball.Radius);
            }

            // Draw direction facing
            _viewer.DrawLine(Color.FromArgb(finalOpacity, Color.White), 2d, ball.Position, dirFacing);

            #region Draw the edge

            switch (mode)
            {
                case DrawMode.Building:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Standard:
                    _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                    break;

                case DrawMode.Selected:
                    _viewer.DrawCircle_Selected(ball.Position, ball.Radius);
                    break;
            }

            #endregion

            //TODO:  Show Stats
        }
Exemple #8
0
        /// <summary>
        /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then
        /// the final opacity is 64)
        /// </summary>
        public void DrawBall(Ball ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;

            #region Figure out the color

            if (drawRed)
            {
                color = REDCOLOR;
            }
            else
            {
                color = Color.Gold;
            }

            #endregion

            int finalOpacity;
            #region Figure out the opacity

            switch (mode)
            {
            case DrawMode.Building:
                finalOpacity = BUILDINGBALLFILLOPACTIY;
                break;

            case DrawMode.Selected:
            case DrawMode.Standard:
                finalOpacity = STANDARDBALLFILLOPACTIY;
                break;

            default:
                throw new ApplicationException("Unknown DrawMode: " + mode.ToString());
            }

            finalOpacity = Convert.ToInt32(finalOpacity * opacity);
            if (finalOpacity < 0)
            {
                finalOpacity = 0;
            }
            else if (finalOpacity > 255)
            {
                finalOpacity = 255;
            }

            #endregion

            // Collision Style
            DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle);

            // Fill the circle
            using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color)))
            {
                _viewer.FillCircle(brush, ball.Position, ball.Radius);
            }

            #region Draw the edge

            switch (mode)
            {
            case DrawMode.Building:
                _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                break;

            case DrawMode.Standard:
                _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                break;

            case DrawMode.Selected:
                _viewer.DrawCircle_Selected(ball.Position, ball.Radius);
                break;
            }

            #endregion

            //TODO:  Show Stats
        }
Exemple #9
0
        /// <summary>
        /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then
        /// the final opacity is 64)
        /// </summary>
        public void DrawSolidBall(SolidBall ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;

            #region Figure out the color

            if (drawRed)
            {
                color = REDCOLOR;
            }
            else
            {
                color = Color.RoyalBlue;
            }

            #endregion

            int finalOpacity;
            #region Figure out the opacity

            switch (mode)
            {
            case DrawMode.Building:
                finalOpacity = BUILDINGBALLFILLOPACTIY;
                break;

            case DrawMode.Selected:
            case DrawMode.Standard:
                finalOpacity = STANDARDBALLFILLOPACTIY;
                break;

            default:
                throw new ApplicationException("Unknown DrawMode: " + mode.ToString());
            }

            finalOpacity = Convert.ToInt32(finalOpacity * opacity);
            if (finalOpacity < 0)
            {
                finalOpacity = 0;
            }
            else if (finalOpacity > 255)
            {
                finalOpacity = 255;
            }

            #endregion

            MyVector dirFacing;
            #region Figure out direction facing

            dirFacing = ball.DirectionFacing.Standard.Clone();
            dirFacing.BecomeUnitVector();
            dirFacing.Multiply(ball.Radius);
            dirFacing.Add(ball.Position);

            #endregion

            // Collision Style
            DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle);

            // Fill the circle
            using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color)))
            {
                _viewer.FillCircle(brush, ball.Position, ball.Radius);
            }

            // Draw direction facing
            _viewer.DrawLine(Color.FromArgb(finalOpacity, Color.White), 2d, ball.Position, dirFacing);

            #region Draw the edge

            switch (mode)
            {
            case DrawMode.Building:
                _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                break;

            case DrawMode.Standard:
                _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                break;

            case DrawMode.Selected:
                _viewer.DrawCircle_Selected(ball.Position, ball.Radius);
                break;
            }

            #endregion

            //TODO:  Show Stats
        }
Exemple #10
0
        internal static void Draw( Player player, Command cmd, DrawMode mode )
        {
            if( !player.Can( Permissions.Draw ) ) {
                player.NoAccessMessage( Permissions.Draw );
                return;
            }
            if( player.drawingInProgress ) {
                player.Message( "Another draw command is already in progress. Please wait." );
                return;
            }
            string blockName = cmd.Next();
            string blockName2 = cmd.Next();
            object blockTypeTag = null;

            Permissions permission = Permissions.Build;

            // if a type is specified in chat, try to parse it
            if( blockName != null ) {
                Block block;
                try {
                    block = Map.GetBlockByName( blockName );
                } catch( Exception ) {
                    try
                    {
                        block = (Block)Convert.ToByte(blockName);
                    }
                    catch (Exception)
                    {
                        player.Message("Unknown block name: " + blockName);
                        return;
                    }
                }
                if ((int)block < 0 || (int)block > 49)
                {
                    player.Message("Invalid block ID!");
                    return;
                }
                switch( block ) {
                    case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;
                    case Block.Air: permission = Permissions.Delete; break;
                    case Block.Water: permission = Permissions.PlaceRealWater; break;
                    case Block.StillWater: permission = Permissions.PlaceWater; break;
                    case Block.Lava: permission = Permissions.PlaceRealLava; break;
                    case Block.StillLava: permission = Permissions.PlaceLava; break;
                }

                blockTypeTag = block;
            }
            else if (mode == DrawMode.Replace)
            {
                player.Message("Not enough parameters!");
                return;
            }

            Block block2 = Block.Undefined;
            if (blockName2 != null && mode == DrawMode.Replace)
            {
                try
                {
                    block2 = Map.GetBlockByName(blockName2);
                }
                catch (Exception)
                {
                    try
                    {
                        block2 = (Block)Convert.ToByte(blockName2);
                    }
                    catch (Exception)
                    {
                        player.Message("Unknown block name: " + blockName2);
                        return;
                    }
                }
                if ((int)block2 < 0 || (int)block2 > 49)
                {
                    player.Message("Invalid block ID!");
                    return;
                }
            }
            else if (mode == DrawMode.Replace && blockName2 == null)
            {
                player.Message("Not enough parameters!");
                return;
            }
            // otherwise, use the last-used-block

            if( !player.Can( permission ) ) {
                player.Message( "You are not allowed to draw with this block." );
                return;
            }

            player.tag = blockTypeTag;
            if(mode == DrawMode.Replace) player.bl2 = block2;
            switch( mode ) {
                case DrawMode.Cuboid:
                    player.selectionCallback = DrawCuboid;
                    player.marksExpected = 2;
                    break;
                case DrawMode.Ellipsoid:
                    player.selectionCallback = DrawEllipsoid;
                    player.marksExpected = 2;
                    break;
                case DrawMode.Fill:
                    player.selectionCallback = DoFill;
                    player.marksExpected = 1;
                    break;
                case DrawMode.Replace:
                    player.selectionCallback = DoReplace;
                    player.marksExpected = 2;
                    break;
            }
            player.markCount = 0;
            player.marks.Clear();
            player.Message( mode.ToString() + ": Place a block or type /mark to use your location." );
        }