internal RoundRectangleShape(Paint2DForm parent, RoundedRect rect, float strokeWidth, int selectedBrush, bool fill)
     : base(parent, fill)
 {
     _rect = rect;
     _strokeWidth = strokeWidth;
     _selectedBrushIndex = selectedBrush;
 }
Пример #2
0
 public RoundRectangleShape(RenderTarget initialRenderTarget, Random random, D2DFactory d2DFactory, D2DBitmap bitmap)
     : base(initialRenderTarget, random, d2DFactory, bitmap)
 {
     rect = RandomRoundedRect();
     double which = Random.NextDouble();
     if (which < 0.67)
         PenBrush = RandomBrush();
     if (which > 0.33)
         FillBrush = RandomBrush();
     if (CoinFlip)
         StrokeStyle = RandomStrokeStyle();
     StrokeWidth = RandomStrokeWidth();
 }
Пример #3
0
        public void DrawCard(Graphics2D DestGraphics, int CardX, int CardY)
        {
            double StartX = CardX * CARD_WIDTH + m_BoardX;
            double StartY = CardY * CARD_HEIGHT + m_BoardY;

            RectangleDouble CardBounds           = new RectangleDouble(StartX + 1.5, StartY + 1.5, StartX + CARD_WIDTH - 1.5, StartY + CARD_HEIGHT - 1.5);
            RoundedRect     CardFiledRoundedRect = new RoundedRect(CardBounds.Left, CardBounds.Bottom, CardBounds.Right, CardBounds.Top, 5);
            Stroke          CardRectBounds       = new Stroke(CardFiledRoundedRect);

            CardRectBounds.width(1);

            CCard  Card        = MomsGame.GetCard(CardX, CardY);
            int    CardValue   = Card.GetValue();
            int    CardSuit    = Card.GetSuit();
            String ValueString = "Uninitialized ";

            if (CardValue > (int)CCard.CARD_VALUE.VALUE_ACE)
            {
                DestGraphics.SetTransform(Affine.NewIdentity());
                DestGraphics.Render(CardRectBounds, new Color(0, 0, 0));
                if (CardValue > 10)
                {
                    switch (CardValue)
                    {
                    case 11:
                        ValueString = "J";
                        break;

                    case 12:
                        ValueString = "Q";
                        break;

                    case 13:
                        ValueString = "K";
                        break;

                    default:
                        throw new Exception();
                    }
                }
                else
                {
                    ValueString = CardValue.ToString();
                }

                TextWidget      stringToDraw = new TextWidget(ValueString, 10);
                RectangleDouble textBounds   = stringToDraw.Printer.LocalBounds;
                DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 2, CardBounds.Top - 8 - textBounds.Height / 2));
                DestGraphics.Render(stringToDraw.Printer, new Color(0, 0, 0));
                DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 4 - textBounds.Width, CardBounds.Bottom + 9 - textBounds.Height / 2));
                DestGraphics.Render(stringToDraw.Printer, new Color(0, 0, 0));

                Color         SuitColor = new Color(0, 0, 0);
                IVertexSource suitPath  = new VertexStorage();

                switch (CardSuit)
                {
                case (int)CCard.CARD_SUIT.SUIT_DIAMOND:
                {
                    SuitColor = new Color(0xFF, 0x11, 0x11);
                    suitPath  = m_DiamondShape;
                }
                break;

                case (int)CCard.CARD_SUIT.SUIT_CLUB:
                {
                    SuitColor = new Color(0x22, 0x22, 0x66);
                    suitPath  = new FlattenCurves(m_ClubShape);
                }
                break;

                case (int)CCard.CARD_SUIT.SUIT_HEART:
                {
                    SuitColor = new Color(0xBB, 0x00, 0x00);
                    suitPath  = new FlattenCurves(m_HeartShape);
                }
                break;

                case (int)CCard.CARD_SUIT.SUIT_SPADE:
                {
                    SuitColor = new Color(0x00, 0x00, 0x00);
                    suitPath  = new FlattenCurves(m_SpadeShape);
                }
                break;

                default:
                    break;
                }

                textBounds = stringToDraw.Printer.LocalBounds;

                if (CardValue < 11)
                {
                    for (int CurDot = 0; CurDot < CardValue; CurDot++)
                    {
                        double OffsetX = 0, OffsetY = 0;
                        GetSuitOffset(ref OffsetX, ref OffsetY, CurDot, (int)CardValue);
                        DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + OffsetX, CardBounds.Bottom + OffsetY));
                        DestGraphics.Render(suitPath, SuitColor);
                    }
                }
                else
                {
                    DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 9, CardBounds.Bottom + 17));
                    DestGraphics.Render(suitPath, SuitColor);
                    DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 9, CardBounds.Top - 17));
                    DestGraphics.Render(suitPath, SuitColor);

                    stringToDraw = new TextWidget(ValueString, 22);
                    textBounds   = stringToDraw.Printer.LocalBounds;
                    DestGraphics.SetTransform(Affine.NewTranslation(-1 + CardBounds.Left + CardBounds.Width / 2 - textBounds.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - textBounds.Height / 2));
                    DestGraphics.Render(stringToDraw.Printer, new Color(0, 0, 0));
                }
            }
            else
            {
                Color HoleColor = new Color(0, 0, 0);

                String OpenSpaceString;

                if (!MomsGame.SpaceIsClickable(CardX, CardY))
                {
                    HoleColor       = new Color(0xf8, 0xe2, 0xe8);
                    OpenSpaceString = "X";
                }
                else
                {
                    HoleColor       = new Color(0xe1, 0xe0, 0xf6);
                    OpenSpaceString = "O";
                }

                TextWidget      stringToDraw = new TextWidget(OpenSpaceString, 35);
                RectangleDouble Size         = stringToDraw.Printer.LocalBounds;
                DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + CardBounds.Width / 2 - Size.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - Size.Height / 2));
                DestGraphics.Render(stringToDraw.Printer, HoleColor);
            }
        }
Пример #4
0
 public void PushClip(RoundedRect clip)
 {
     CheckLease();
     Canvas.Save();
     Canvas.ClipRoundRect(clip.ToSKRoundRect(), antialias: true);
 }
Пример #5
0
        public void Draw(MatterHackers.Agg.Transform.ITransform Position, Graphics2D renderer)
        {
            double TextHeight = m_Position.Y - 20;
            double Range      = (m_DataViewMaxY - m_DataViewMinY);
            VertexSourceApplyTransform TransformedLinesToDraw;
            Stroke StrockedTransformedLinesToDraw;

            RoundedRect BackGround = new RoundedRect(m_Position.X, m_Position.Y - 1, m_Position.X + m_Width, m_Position.Y - 1 + m_Height + 2, 5);
            VertexSourceApplyTransform TransformedBackGround = new VertexSourceApplyTransform(BackGround, Position);

            renderer.Render(TransformedBackGround, new Color(0, 0, 0, .5));

            // if the 0 line is within the window than draw it.
            if (m_DataViewMinY < 0 && m_DataViewMaxY > 0)
            {
                m_LinesToDraw.remove_all();
                m_LinesToDraw.MoveTo(m_Position.X,
                                     m_Position.Y + ((0 - m_DataViewMinY) * m_Height / Range));
                m_LinesToDraw.LineTo(m_Position.X + m_Width,
                                     m_Position.Y + ((0 - m_DataViewMinY) * m_Height / Range));
                TransformedLinesToDraw         = new VertexSourceApplyTransform(m_LinesToDraw, Position);
                StrockedTransformedLinesToDraw = new Stroke(TransformedLinesToDraw);
                renderer.Render(StrockedTransformedLinesToDraw, new Color(0, 0, 0, 1));
            }

            double MaxMax     = -999999999;
            double MinMin     = 999999999;
            double MaxAverage = 0;

            foreach (KeyValuePair <String, HistoryData> historyKeyValue in m_DataHistoryArray)
            {
                HistoryData history = historyKeyValue.Value;
                m_LinesToDraw.remove_all();
                MaxMax     = System.Math.Max(MaxMax, history.GetMaxValue());
                MinMin     = System.Math.Min(MinMin, history.GetMinValue());
                MaxAverage = System.Math.Max(MaxAverage, history.GetAverageValue());
                for (int i = 0; i < m_Width - 1; i++)
                {
                    if (i == 0)
                    {
                        m_LinesToDraw.MoveTo(m_Position.X + i,
                                             m_Position.Y + ((history.GetItem(i) - m_DataViewMinY) * m_Height / Range));
                    }
                    else
                    {
                        m_LinesToDraw.LineTo(m_Position.X + i,
                                             m_Position.Y + ((history.GetItem(i) - m_DataViewMinY) * m_Height / Range));
                    }
                }

                TransformedLinesToDraw         = new VertexSourceApplyTransform(m_LinesToDraw, Position);
                StrockedTransformedLinesToDraw = new Stroke(TransformedLinesToDraw);
                renderer.Render(StrockedTransformedLinesToDraw, history.m_Color);

                String Text = historyKeyValue.Key + ": Min:" + MinMin.ToString("0.0") + " Max:" + MaxMax.ToString("0.0");
                renderer.DrawString(Text, m_Position.X, TextHeight - m_Height);
                TextHeight -= 20;
            }

            RoundedRect BackGround2 = new RoundedRect(m_Position.X, m_Position.Y - 1, m_Position.X + m_Width, m_Position.Y - 1 + m_Height + 2, 5);
            VertexSourceApplyTransform TransformedBackGround2 = new VertexSourceApplyTransform(BackGround2, Position);
            Stroke StrockedTransformedBackGround = new Stroke(TransformedBackGround2);

            renderer.Render(StrockedTransformedBackGround, new Color(0.0, 0, 0, 1));

            //renderer.Color = BoxColor;
            //renderer.DrawRect(m_Position.x, m_Position.y - 1, m_Width, m_Height + 2);
        }
Пример #6
0
 public void PushClip(RoundedRect clip)
 {
     //TODO: radius
     _deviceContext.PushAxisAlignedClip(clip.Rect.ToDirect2D(), AntialiasMode.PerPrimitive);
 }
Пример #7
0
        public void SavingFunction()
        {
            currentlySaving        = true;
            countThatHaveBeenSaved = 0;
            // first create images for all the parts
            foreach (FileNameAndPresentationName queuePartFileName in queuPartFilesToAdd)
            {
                List <MeshGroup> loadedMeshGroups = MeshFileIo.Load(queuePartFileName.fileName);
                if (loadedMeshGroups != null)
                {
                    bool firstMeshGroup         = true;
                    AxisAlignedBoundingBox aabb = null;
                    foreach (MeshGroup meshGroup in loadedMeshGroups)
                    {
                        if (firstMeshGroup)
                        {
                            aabb           = meshGroup.GetAxisAlignedBoundingBox();
                            firstMeshGroup = false;
                        }
                        else
                        {
                            aabb = AxisAlignedBoundingBox.Union(aabb, meshGroup.GetAxisAlignedBoundingBox());
                        }
                    }
                    RectangleDouble bounds2D    = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                    double          widthInMM   = bounds2D.Width + PartMarginMM * 2;
                    double          textSpaceMM = 5;
                    double          heightMM    = textSpaceMM + bounds2D.Height + PartMarginMM * 2;

                    TypeFacePrinter typeFacePrinter = new TypeFacePrinter(queuePartFileName.presentationName, 28, Vector2.Zero, Justification.Center, Baseline.BoundsCenter);
                    double          sizeOfNameX     = typeFacePrinter.GetSize().x + PartMarginPixels * 2;
                    Vector2         sizeOfRender    = new Vector2(widthInMM * PixelPerMM, heightMM * PixelPerMM);

                    ImageBuffer imageOfPart = new ImageBuffer((int)(Math.Max(sizeOfNameX, sizeOfRender.x)), (int)(sizeOfRender.y), 32, new BlenderBGRA());
                    typeFacePrinter.Origin = new Vector2(imageOfPart.Width / 2, (textSpaceMM / 2) * PixelPerMM);

                    Graphics2D partGraphics2D = imageOfPart.NewGraphics2D();

                    RectangleDouble rectBounds  = new RectangleDouble(0, 0, imageOfPart.Width, imageOfPart.Height);
                    double          strokeWidth = .5 * PixelPerMM;
                    rectBounds.Inflate(-strokeWidth / 2);
                    RoundedRect rect = new RoundedRect(rectBounds, PartMarginMM * PixelPerMM);
                    partGraphics2D.Render(rect, RGBA_Bytes.LightGray);
                    Stroke rectOutline = new Stroke(rect, strokeWidth);
                    partGraphics2D.Render(rectOutline, RGBA_Bytes.DarkGray);

                    foreach (MeshGroup meshGroup in loadedMeshGroups)
                    {
                        foreach (Mesh loadedMesh in meshGroup.Meshes)
                        {
                            PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh, new Vector2(-bounds2D.Left + PartMarginMM, -bounds2D.Bottom + textSpaceMM + PartMarginMM), PixelPerMM, RGBA_Bytes.Black);
                        }
                    }
                    partGraphics2D.Render(typeFacePrinter, RGBA_Bytes.Black);

                    partImagesToPrint.Add(new PartImage(imageOfPart));

                    countThatHaveBeenSaved++;
                }

                if (UpdateRemainingItems != null)
                {
                    UpdateRemainingItems(this, new StringEventArgs(Path.GetFileName(queuePartFileName.presentationName)));
                }
            }

            partImagesToPrint.Sort(BiggestToLittlestImages);

            PdfDocument document = new PdfDocument();

            document.Info.Title    = "MatterHackers Parts Sheet";
            document.Info.Author   = "MatterHackers Inc.";
            document.Info.Subject  = "This is a list of the parts that are in a queue from MatterControl.";
            document.Info.Keywords = "MatterControl, STL, 3D Printing";

            int  nextPartToPrintIndex = 0;
            int  plateNumber          = 1;
            bool done = false;

            while (!done && nextPartToPrintIndex < partImagesToPrint.Count)
            {
                PdfPage pdfPage = document.AddPage();
                CreateOnePage(plateNumber++, ref nextPartToPrintIndex, pdfPage);
            }
            try
            {
                // save the final document
                document.Save(pathAndFileToSaveTo);
                // Now try and open the document. This will lanch whatever PDF viewer is on the system and ask it
                // to show the file (at least on Windows).
                Process.Start(pathAndFileToSaveTo);
            }
            catch (Exception)
            {
            }

            OnDoneSaving();
            currentlySaving = false;
        }
Пример #8
0
 public PushedState PushClip(RoundedRect clip)
 {
     PlatformImpl.PushClip(clip);
     return(new PushedState(this, PushedState.PushedStateType.Clip));
 }
Пример #9
0
        public override async Task Rebuild()
        {
            using (RebuildLock())
            {
                using (new CenterAndHeightMaintainer(this))
                {
                    this.Children.Modify(list =>
                    {
                        list.Clear();
                    });

                    var brailleLetter = new BrailleObject3D()
                    {
                        TextToEncode = Letter.ToString(),
                        BaseHeight   = BaseHeight,
                    };
                    await brailleLetter.Rebuild();

                    this.Children.Add(brailleLetter);

                    var textObject = new TextObject3D()
                    {
                        PointSize   = 46,
                        Color       = Color.LightBlue,
                        NameToWrite = Letter.ToString(),
                        Height      = BaseHeight
                    };

                    await textObject.Rebuild();

                    IObject3D letterObject = new RotateObject3D_2(textObject, Vector3.UnitX, -90);
                    await letterObject.Rebuild();

                    var scaleRatio = Math.Max(letterObject.XSize() / 17, letterObject.ZSize() / 17);
                    if (scaleRatio > 1)
                    {
                        letterObject = new ScaleObject3D_3(letterObject, 1.0 / scaleRatio, 1, 1.0 / scaleRatio);
                    }
                    letterObject = new AlignObject3D(letterObject, FaceAlign.Bottom | FaceAlign.Front, brailleLetter, FaceAlign.Top | FaceAlign.Front, 0, 0, 3.5);
                    letterObject = new SetCenterObject3D(letterObject, brailleLetter.GetCenter(), true, false, false);
                    this.Children.Add(letterObject);

                    var basePath = new RoundedRect(0, 0, 22, 34, 3)
                    {
                        ResolutionScale = 10
                    };

                    IObject3D basePlate = new Object3D()
                    {
                        Mesh   = VertexSourceToMesh.Extrude(basePath, BaseHeight),
                        Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 4)
                    };

                    basePlate = new AlignObject3D(basePlate, FaceAlign.Bottom | FaceAlign.Back, brailleLetter, FaceAlign.Bottom | FaceAlign.Back);
                    basePlate = new SetCenterObject3D(basePlate, brailleLetter.GetCenter(), true, false, false);
                    this.Children.Add(basePlate);

                    IObject3D underline = await CubeObject3D.Create(basePlate.XSize(), .2, 1);

                    underline = new AlignObject3D(underline, FaceAlign.Bottom, brailleLetter, FaceAlign.Top);
                    underline = new AlignObject3D(underline, FaceAlign.Back | FaceAlign.Left, basePlate, FaceAlign.Front | FaceAlign.Left, 0, .01);
                    this.Children.Add(underline);
                }
            }

            Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
        }
Пример #10
0
        public override void OnDraw()
        {
            GammaLut            gamma         = new GammaLut(m_gamma.value().ToDouble());
            IBlender            NormalBlender = new BlenderBGRA();
            IBlender            GammaBlender  = new BlenderGammaBGRA(gamma);
            FormatRGBA          pixf          = new FormatRGBA(rbuf_window(), NormalBlender);
            FormatClippingProxy clippingProxy = new FormatClippingProxy(pixf);

            clippingProxy.Clear(m_white_on_black.status() ? new RGBA_Doubles(0, 0, 0) : new RGBA_Doubles(1, 1, 1));

            RasterizerScanlineAA <T> ras = new RasterizerScanlineAA <T>();
            ScanlinePacked8          sl  = new ScanlinePacked8();

            Ellipse <T> e = new Ellipse <T>();

            // TODO: If you drag the control circles below the bottom of the window we get an exception.  This does not happen in AGG.
            // It needs to be debugged.  Turning on clipping fixes it.  But standard agg works without clipping.  Could be a bigger problem than this.
            //ras.clip_box(0, 0, width(), height());

            // Render two "control" circles
            e.Init(m_x[0], m_y[0], M.New <T>(3), M.New <T>(3), 16);
            ras.AddPath(e);
            Renderer <T> .RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(127, 127, 127));

            e.Init(m_x[1], m_y[1], M.New <T>(3), M.New <T>(3), 16);
            ras.AddPath(e);
            Renderer <T> .RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(127, 127, 127));

            T d = m_offset.value();

            // Creating a rounded rectangle
            RoundedRect <T> r = new RoundedRect <T>(m_x[0].Add(d), m_y[0].Add(d), m_x[1].Add(d), m_y[1].Add(d), m_radius.value());

            r.NormalizeRadius();

            // Drawing as an outline
            if (!m_DrawAsOutlineCheckBox.status())
            {
                ConvStroke <T> p = new ConvStroke <T>(r);
                p.Width = M.One <T>();
                ras.AddPath(p);
            }
            else
            {
                ras.AddPath(r);
            }

            pixf.Blender = GammaBlender;
            Renderer <T> .RenderSolid(clippingProxy, ras, sl, m_white_on_black.status()?new RGBA_Bytes(1, 1, 1) : new RGBA_Bytes(0, 0, 0));

            // this was in the original demo, but it does nothing because we changed the blender not the gamma function.
            //ras.gamma(new gamma_none());
            // so let's change the blender instead
            pixf.Blender = NormalBlender;

            // Render the controls
            //m_radius.Render(ras, sl, clippingProxy);
            //m_gamma.Render(ras, sl, clippingProxy);
            //m_offset.Render(ras, sl, clippingProxy);
            //m_white_on_black.Render(ras, sl, clippingProxy);
            //m_DrawAsOutlineCheckBox.Render(ras, sl, clippingProxy);
            base.OnDraw();
        }
Пример #11
0
        public override void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor)
        {
            var rect = new RoundedRect(left, bottom, right, top, 0);

            Render(rect, fillColor.ToColor());
        }
Пример #12
0
        protected override INode CreateFigure(MemoShape model)
        {
            var ret = default(INode);

            switch (model.Kind)
            {
            case MemoShapeKind.RoundRect: {
                ret = new RoundedRect();
                break;
            }

            case MemoShapeKind.Triangle: {
                ret = new Triangle();
                break;
            }

            case MemoShapeKind.Ellipse: {
                ret = new Ellipse();
                break;
            }

            case MemoShapeKind.Diamond: {
                ret = new Diamond();
                break;
            }

            case MemoShapeKind.Parallelogram: {
                ret = new Parallelogram();
                break;
            }

            case MemoShapeKind.Cylinder: {
                ret = new Cylinder();
                break;
            }

            case MemoShapeKind.Paper: {
                ret = new Paper();
                break;
            }

            case MemoShapeKind.LeftArrow: {
                ret = new ArrowFigure(Directions.Left);
                break;
            }

            case MemoShapeKind.RightArrow: {
                ret = new ArrowFigure(Directions.Right);
                break;
            }

            case MemoShapeKind.UpArrow: {
                ret = new ArrowFigure(Directions.Up);
                break;
            }

            case MemoShapeKind.DownArrow: {
                ret = new ArrowFigure(Directions.Down);
                break;
            }

            case MemoShapeKind.LeftRightArrow: {
                ret = new TwoHeadArrowFigure(false);
                break;
            }

            case MemoShapeKind.UpDownArrow: {
                ret = new TwoHeadArrowFigure(true);
                break;
            }

            case MemoShapeKind.Pentagon: {
                ret = new Pentagon();
                break;
            }

            case MemoShapeKind.Chevron: {
                ret = new Chevron();
                break;
            }

            case MemoShapeKind.Equal: {
                ret = new EqualFigure(false);
                break;
            }

            case MemoShapeKind.NotEqual: {
                ret = new EqualFigure(true);
                break;
            }

            case MemoShapeKind.Plus: {
                ret = new PlusFigure();
                break;
            }

            case MemoShapeKind.Minus: {
                ret = new MinusFigure();
                break;
            }

            case MemoShapeKind.Times: {
                ret = new TimesFigure();
                break;
            }

            case MemoShapeKind.Devide: {
                ret = new DevideFigure();
                break;
            }

            case MemoShapeKind.Rect:
            default: {
                ret = new Rect();
                break;
            }
            }

            ret.BorderWidth = 1;
            ret.Background  = new GradientBrushDescription(
                Color.FromArgb(230, 240, 255),
                Color.FromArgb(200, 220, 240),
                90f
                );

            ret.Foreground = Color.FromArgb(75, 125, 190);
            ret.MinSize    = new Size(16, 16);
            //ret.AutoSizeKinds = AutoSizeKinds.GrowBoth;

            return(ret);
        }
        public LobbyFinderMenu(ProcessManager manager) : base(manager, ProcessManager.ProcessID.MainMenu)
        {
            #region UI ELEMENTS SIZE DEFINITION
            float resOffset = (1366 - manager.rainWorld.screenSize.x) / 2; // shift everything to the right depending on the resolution. 1/2 of the diff with the max resolution.

            float screenWidth  = manager.rainWorld.screenSize.x;
            float screenHeight = manager.rainWorld.screenSize.y;
            // initialize some dynamic sizes and positions for UI elements.
            // player list and multiplayer settings have the same size no matter what the resolution.
            // the room chat adjusts to fill all the middle space
            float panelGutter = 15;                                                                            // gap width between the panels

            float multiplayerSettingsWidth       = 300;                                                        // constant
            float multiplayerSettingsSliderWidth = multiplayerSettingsWidth - 115;                             // constant

            float multiplayerSettingsPositionX       = screenWidth - (multiplayerSettingsWidth + panelGutter); // position depending on screen width
            float multiplayerSettingsSliderPositionX = multiplayerSettingsPositionX + 10;                      // constant

            float controlButtonSpaceHeight = 100;                                                              // constant
            float panelHeight    = screenHeight - (controlButtonSpaceHeight + panelGutter * 2);                // leaving a space for bottom control buttons
            float panelPositionY = controlButtonSpaceHeight;                                                   // constant

            float lobbyFinderHeight    = screenHeight - (controlButtonSpaceHeight + (panelGutter) + 50);       // leaving a space for top and bottom control buttons
            float lobbyFinderWidth     = (screenWidth - (multiplayerSettingsWidth + panelGutter * 3)) / 1.5f;  // depends on resolution
            float lobbyFinderPositionX = resOffset + panelGutter;
            float lobbyFinderPositionY = panelPositionY;

            float lobbyCreatorHeight          = screenHeight - (controlButtonSpaceHeight + panelGutter * 2);
            float lobbyCreatorWidth           = screenWidth - (multiplayerSettingsWidth + lobbyFinderWidth + panelGutter * 4);
            float privacyButtonWidth          = (lobbyCreatorWidth - 20 - (panelGutter * 2)) / 3f;
            float lobbyCreatorSliderWidth     = lobbyCreatorWidth - 115;
            float lobbyCreatorPositionX       = resOffset + panelGutter * 2 + lobbyFinderWidth;
            float lobbyCreatorPositionY       = panelPositionY;
            float lobbyCreatorSliderPositionX = lobbyCreatorPositionX + 10;
            #endregion

            this.lobbynum      = 0;
            hosting            = true;
            this.blackFade     = 1f;
            this.lastBlackFade = 1f;
            this.pages.Add(new Page(this, null, "main", 0));
            //this.scene = new InteractiveMenuScene( this, this.pages[0], MenuScene.SceneID.Landscape_SU );
            //this.pages[0].subObjects.Add( this.scene );
            this.darkSprite         = new FSprite("pixel", true);
            this.darkSprite.color   = new Color(0f, 0f, 0f);
            this.darkSprite.anchorX = 0f;
            this.darkSprite.anchorY = 0f;
            this.darkSprite.scaleX  = screenWidth;
            this.darkSprite.scaleY  = screenHeight;
            this.darkSprite.x       = screenWidth / 2f;
            this.darkSprite.y       = screenHeight / 2f;
            this.darkSprite.alpha   = 0.85f;
            this.pages[0].Container.AddChild(this.darkSprite);
            this.blackFadeSprite        = new FSprite("Futile_White", true);
            this.blackFadeSprite.scaleX = 87.5f;
            this.blackFadeSprite.scaleY = 50f;
            this.blackFadeSprite.x      = screenWidth / 2f;
            this.blackFadeSprite.y      = screenHeight / 2f;
            this.blackFadeSprite.color  = new Color(0f, 0f, 0f);
            Futile.stage.AddChild(this.blackFadeSprite);

            //Multiplayer Settings Box
            colorBox = new RoundedRect(this, this.pages[0], new Vector2(resOffset + multiplayerSettingsPositionX, panelPositionY), new Vector2(multiplayerSettingsWidth, panelHeight), false);
            this.pages[0].subObjects.Add(colorBox);

            //Settings Label
            settingsLabel = new FLabel("font", "Multiplayer Settings");
            settingsLabel.SetPosition(new Vector2(multiplayerSettingsPositionX + 70, screenHeight - 60));
            Futile.stage.AddChild(this.settingsLabel);

            //Body Color Label
            bodyLabel = new FLabel("font", "Body Color");
            bodyLabel.SetPosition(new Vector2(multiplayerSettingsPositionX + 70, screenHeight - 90));
            Futile.stage.AddChild(this.bodyLabel);

            //Red Slider
            bodyRed                       = new HorizontalSlider(this, this.pages[0], "Red", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 130), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)patch_Slider.SliderID.BodyRed, false);
            bodyRed.floatValue            = MonklandSteamManager.bodyColor.r;
            bodyRed.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyRed);
            //Green Slider
            bodyGreen                       = new HorizontalSlider(this, this.pages[0], "Green", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 170), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)patch_Slider.SliderID.BodyGreen, false);
            bodyGreen.floatValue            = MonklandSteamManager.bodyColor.g;
            bodyGreen.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyGreen);
            //Blue Slider
            bodyBlue                       = new HorizontalSlider(this, this.pages[0], "Blue", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 210), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)patch_Slider.SliderID.BodyBlue, false);
            bodyBlue.floatValue            = MonklandSteamManager.bodyColor.b;
            bodyBlue.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyBlue);

            //Eye Color Label
            eyesLabel = new FLabel("font", "Eye Color");
            eyesLabel.SetPosition(new Vector2(multiplayerSettingsPositionX + 70, screenHeight - 240));
            Futile.stage.AddChild(this.eyesLabel);

            //Red Slider
            eyesRed            = new HorizontalSlider(this, this.pages[0], "Red ", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 280), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)patch_Slider.SliderID.EyesRed, false);
            eyesRed.floatValue = MonklandSteamManager.eyeColor.r;
            this.pages[0].subObjects.Add(this.eyesRed);
            //Green Slider
            eyesGreen            = new HorizontalSlider(this, this.pages[0], "Green ", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 320), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)patch_Slider.SliderID.EyesGreen, false);
            eyesGreen.floatValue = MonklandSteamManager.eyeColor.g;
            this.pages[0].subObjects.Add(this.eyesGreen);
            //Blue Slider
            eyesBlue            = new HorizontalSlider(this, this.pages[0], "Blue ", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 360), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)patch_Slider.SliderID.EyesBlue, false);
            eyesBlue.floatValue = MonklandSteamManager.eyeColor.b;
            this.pages[0].subObjects.Add(this.eyesBlue);


            //Slugcat Eyes Sprite
            eyes           = new FSprite("FoodCircleB", true);
            eyes.scaleX    = 1f;
            eyes.scaleY    = 1.1f;
            eyes.color     = new Color(0, 0, 0);
            eyes.x         = multiplayerSettingsPositionX + 130;
            eyes.y         = manager.rainWorld.screenSize.y - 236;
            eyes.isVisible = true;
            this.pages[0].Container.AddChild(this.eyes);

            //Slugcat Sprite
            slugcat           = new FSprite("slugcatSleeping", true);
            slugcat.scaleX    = 1f;
            slugcat.scaleY    = 1f;
            slugcat.color     = new Color(1f, 1f, 1f);
            slugcat.x         = multiplayerSettingsPositionX + 136;
            slugcat.y         = manager.rainWorld.screenSize.y - 235;
            slugcat.isVisible = true;
            this.pages[0].Container.AddChild(this.slugcat);

            //Slugcat Buttons
            this.slugcatButtons    = new SelectOneButton[3];
            this.slugcatButtons[0] = new SelectOneButton(this, this.pages[0], base.Translate("SURVIOR"), "Slugcat", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 445f), new Vector2(110f, 30f), this.slugcatButtons, 0);
            this.pages[0].subObjects.Add(this.slugcatButtons[0]);
            this.slugcatButtons[1] = new SelectOneButton(this, this.pages[0], base.Translate("MONK"), "Slugcat", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 490f), new Vector2(110f, 30f), this.slugcatButtons, 1);
            this.pages[0].subObjects.Add(this.slugcatButtons[1]);
            this.slugcatButtons[2] = new SelectOneButton(this, this.pages[0], base.Translate("HUNTER"), "Slugcat", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 535f), new Vector2(110f, 30f), this.slugcatButtons, 2);
            this.pages[0].subObjects.Add(this.slugcatButtons[2]);

            //Debug Mode checkbox
            this.debugCheckBox = new CheckBox(this, this.pages[0], this, new Vector2(resOffset + multiplayerSettingsSliderPositionX + 120, screenHeight - 400), 120f, "Debug Mode", "DEBUG");
            this.pages[0].subObjects.Add(this.debugCheckBox);

            //Back button
            this.backButton = new SimpleButton(this, this.pages[0], base.Translate("BACK"), "EXIT", new Vector2(resOffset + 15f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.backButton);

            //Lobby Finder Box
            lobbyFinderBox = new RoundedRect(this, this.pages[0], new Vector2(lobbyFinderPositionX, lobbyFinderPositionY), new Vector2(lobbyFinderWidth, lobbyFinderHeight), false);
            this.pages[0].subObjects.Add(lobbyFinderBox);

            //Refresh button
            this.refreshButton = new SimpleButton(this, this.pages[0], "Refresh", "REFRESH", new Vector2(lobbyFinderPositionX + lobbyFinderWidth - 110, screenHeight - 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.refreshButton);

            //Lobby browser Labels:
            this.namesLabel = new FLabel("font", "CREATED BY");
            this.namesLabel.SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + (lobbyFinderWidth / 10), screenHeight - 75));
            Futile.stage.AddChild(this.namesLabel);

            this.versionsLabel = new FLabel("font", "VERSION");
            this.versionsLabel.SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + 1.8f * (lobbyFinderWidth / 5), screenHeight - 75));
            Futile.stage.AddChild(this.versionsLabel);

            this.playersLabel = new FLabel("font", "PLAYERS");
            this.playersLabel.SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + 2.9f * (lobbyFinderWidth / 5), screenHeight - 75));
            Futile.stage.AddChild(this.playersLabel);

            this.maxLabel = new FLabel("font", "MAX");
            this.maxLabel.SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + 4 * (lobbyFinderWidth / 6), screenHeight - 75));
            Futile.stage.AddChild(this.maxLabel);

            //Join buttons
            this.joinButtons       = new SimpleButton[15];
            this.lobbynames        = new FLabel[this.joinButtons.Length];
            this.lobbyVersions     = new FLabel[this.joinButtons.Length];
            this.lobbyPlayerCounts = new FLabel[this.joinButtons.Length];
            this.lobbyPlayerMaxs   = new FLabel[this.joinButtons.Length];
            float buttonheight = (lobbyFinderHeight - 30) / this.joinButtons.Length;
            for (int i = 0; i < this.joinButtons.Length; i++)
            {
                this.lobbynames[i] = new FLabel("font", "-");
                this.lobbynames[i].SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + (lobbyFinderWidth / 10), screenHeight - 100f - (buttonheight * i)));
                Futile.stage.AddChild(this.lobbynames[i]);

                this.lobbyVersions[i] = new FLabel("font", "-");
                this.lobbyVersions[i].SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + 1.8f * (lobbyFinderWidth / 5), screenHeight - 100f - (buttonheight * i)));
                Futile.stage.AddChild(this.lobbyVersions[i]);

                this.lobbyPlayerCounts[i] = new FLabel("font", "-");
                this.lobbyPlayerCounts[i].SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + 2.9f * (lobbyFinderWidth / 5), screenHeight - 100f - (buttonheight * i)));
                Futile.stage.AddChild(this.lobbyPlayerCounts[i]);

                this.lobbyPlayerMaxs[i] = new FLabel("font", "-");
                this.lobbyPlayerMaxs[i].SetPosition(new Vector2(lobbyFinderPositionX + 60 - resOffset + 4 * (lobbyFinderWidth / 6), screenHeight - 100f - (buttonheight * i)));
                Futile.stage.AddChild(this.lobbyPlayerMaxs[i]);

                this.joinButtons[i] = new SimpleButton(this, this.pages[0], "Join", "JOIN" + i, new Vector2(lobbyFinderPositionX + lobbyFinderWidth - 75f, screenHeight - 110f - (buttonheight * i)), new Vector2(60f, buttonheight - 10));
                this.pages[0].subObjects.Add(this.joinButtons[i]);
            }

            //Host or Join Buttons
            this.modeButtons    = new SelectOneButton[2];
            this.modeButtons[1] = new SelectOneButton(this, this.pages[0], base.Translate("JOIN"), "Mode", new Vector2(resOffset + 15, screenHeight - 50f), new Vector2(110f, 30f), this.modeButtons, 1);
            this.pages[0].subObjects.Add(this.modeButtons[1]);
            this.modeButtons[0] = new SelectOneButton(this, this.pages[0], base.Translate("HOST"), "Mode", new Vector2(resOffset + 140, screenHeight - 50f), new Vector2(110f, 30f), this.modeButtons, 0);
            this.pages[0].subObjects.Add(this.modeButtons[0]);

            //Lobby Creator Box
            lobbyFinderBox = new RoundedRect(this, this.pages[0], new Vector2(lobbyCreatorPositionX, lobbyCreatorPositionY), new Vector2(lobbyCreatorWidth, lobbyCreatorHeight), false);
            this.pages[0].subObjects.Add(lobbyFinderBox);

            //Lobby Creator Label
            creatorLabel = new FLabel("font", "Lobby Settings");
            creatorLabel.SetPosition(new Vector2(lobbyCreatorPositionX + 60 - resOffset, screenHeight - 60));
            Futile.stage.AddChild(this.creatorLabel);

            //Lobby Type Buttons
            this.privacyButtons    = new SelectOneButton[3];
            this.privacyButtons[0] = new SelectOneButton(this, this.pages[0], base.Translate("PUBLIC"), "LobbyType", new Vector2(lobbyCreatorSliderPositionX, screenHeight - 130f), new Vector2(privacyButtonWidth, 30f), this.slugcatButtons, 0);
            this.pages[0].subObjects.Add(this.privacyButtons[0]);
            this.privacyButtons[1] = new SelectOneButton(this, this.pages[0], base.Translate("FRIENDS"), "LobbyType", new Vector2(lobbyCreatorSliderPositionX + privacyButtonWidth + 15, screenHeight - 130f), new Vector2(privacyButtonWidth, 30f), this.slugcatButtons, 1);
            this.pages[0].subObjects.Add(this.privacyButtons[1]);
            this.privacyButtons[2] = new SelectOneButton(this, this.pages[0], base.Translate("PRIVATE"), "LobbyType", new Vector2(lobbyCreatorSliderPositionX + 2 * privacyButtonWidth + 30, screenHeight - 130f), new Vector2(privacyButtonWidth, 30f), this.slugcatButtons, 2);
            this.pages[0].subObjects.Add(this.privacyButtons[2]);

            //Players Slider
            maxPlayersSlider                       = new HorizontalSlider(this, this.pages[0], "", new Vector2(lobbyCreatorSliderPositionX, screenHeight - 170), new Vector2(lobbyCreatorSliderWidth + 70, 30), (Slider.SliderID)patch_Slider.SliderID.MaxPlayers, false);
            maxPlayersSlider.floatValue            = 10f / 100f;
            maxPlayersSlider.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.maxPlayersSlider);

            //Max Players Label
            maxPlayersLabel = new FLabel("font", "Max Players: 10");
            maxPlayersLabel.SetPosition(new Vector2(lobbyCreatorSliderPositionX + (lobbyCreatorWidth / 2) - 20 - resOffset, screenHeight - 200));
            Futile.stage.AddChild(this.maxPlayersLabel);

            //Spears checkbox
            this.spearsHitBox = new CheckBox(this, this.pages[0], this, new Vector2(lobbyCreatorSliderPositionX + 120, screenHeight - 250), 120f, "Spears Hit", "SPEARSHIT");
            this.pages[0].subObjects.Add(this.spearsHitBox);

            //Allow Debug checkbox
            this.debugAllowBox = new CheckBox(this, this.pages[0], this, new Vector2(lobbyCreatorSliderPositionX + 120, screenHeight - 280), 120f, "Allow Debug Mode", "ALLOWDEBUG");
            this.pages[0].subObjects.Add(this.debugAllowBox);

            //Start Game button
            this.startLobbyButton = new SimpleButton(this, this.pages[0], "Start Lobby", "STARTLOBBY", new Vector2(lobbyCreatorPositionX + lobbyCreatorWidth - 110, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.startLobbyButton);

            //Controller Combatability
            this.bodyRed.nextSelectable[0]           = this.privacyButtons[2];
            this.bodyRed.nextSelectable[1]           = this.startLobbyButton;
            this.bodyRed.nextSelectable[3]           = this.bodyGreen;
            this.bodyRed.nextSelectable[2]           = this.modeButtons[1];
            this.bodyGreen.nextSelectable[0]         = this.maxPlayersSlider;
            this.bodyGreen.nextSelectable[1]         = this.bodyRed;
            this.bodyGreen.nextSelectable[3]         = this.bodyBlue;
            this.bodyGreen.nextSelectable[2]         = this.modeButtons[1];
            this.bodyBlue.nextSelectable[0]          = this.maxPlayersSlider;
            this.bodyBlue.nextSelectable[1]          = this.bodyGreen;
            this.bodyBlue.nextSelectable[3]          = this.eyesRed;
            this.bodyBlue.nextSelectable[2]          = this.modeButtons[1];
            this.eyesRed.nextSelectable[0]           = this.spearsHitBox;
            this.eyesRed.nextSelectable[1]           = this.bodyBlue;
            this.eyesRed.nextSelectable[3]           = this.eyesGreen;
            this.eyesRed.nextSelectable[2]           = this.modeButtons[1];
            this.eyesGreen.nextSelectable[0]         = this.debugAllowBox;
            this.eyesGreen.nextSelectable[1]         = this.eyesRed;
            this.eyesGreen.nextSelectable[3]         = this.eyesBlue;
            this.eyesGreen.nextSelectable[2]         = this.modeButtons[1];
            this.eyesBlue.nextSelectable[0]          = this.debugAllowBox;
            this.eyesBlue.nextSelectable[1]          = this.eyesGreen;
            this.eyesBlue.nextSelectable[3]          = this.debugCheckBox;
            this.eyesBlue.nextSelectable[2]          = this.modeButtons[1];
            this.debugCheckBox.nextSelectable[0]     = this.debugAllowBox;
            this.debugCheckBox.nextSelectable[1]     = this.eyesBlue;
            this.debugCheckBox.nextSelectable[3]     = this.slugcatButtons[0];
            this.debugCheckBox.nextSelectable[2]     = this.backButton;
            this.slugcatButtons[0].nextSelectable[0] = this.debugAllowBox;
            this.slugcatButtons[0].nextSelectable[1] = this.debugCheckBox;
            this.slugcatButtons[0].nextSelectable[3] = this.slugcatButtons[1];
            this.slugcatButtons[0].nextSelectable[2] = this.backButton;
            this.slugcatButtons[1].nextSelectable[0] = this.debugAllowBox;
            this.slugcatButtons[1].nextSelectable[1] = this.slugcatButtons[0];
            this.slugcatButtons[1].nextSelectable[3] = this.slugcatButtons[2];
            this.slugcatButtons[1].nextSelectable[2] = this.backButton;
            this.slugcatButtons[2].nextSelectable[0] = this.debugAllowBox;
            this.slugcatButtons[2].nextSelectable[1] = this.slugcatButtons[1];
            this.slugcatButtons[2].nextSelectable[3] = this.startLobbyButton;
            this.slugcatButtons[2].nextSelectable[2] = this.backButton;
            this.backButton.nextSelectable[0]        = this.startLobbyButton;
            this.backButton.nextSelectable[1]        = this.modeButtons[1];
            this.backButton.nextSelectable[3]        = this.modeButtons[1];
            this.backButton.nextSelectable[2]        = this.startLobbyButton;
            this.startLobbyButton.nextSelectable[0]  = this.backButton;
            this.startLobbyButton.nextSelectable[1]  = this.debugAllowBox;
            this.startLobbyButton.nextSelectable[3]  = this.privacyButtons[2];
            this.startLobbyButton.nextSelectable[2]  = this.backButton;
            this.modeButtons[1].nextSelectable[0]    = this.bodyRed;
            this.modeButtons[1].nextSelectable[1]    = this.backButton;
            this.modeButtons[1].nextSelectable[3]    = this.backButton;
            this.modeButtons[1].nextSelectable[2]    = this.modeButtons[0];
            this.modeButtons[0].nextSelectable[0]    = this.modeButtons[1];
            this.modeButtons[0].nextSelectable[1]    = this.backButton;
            this.modeButtons[0].nextSelectable[3]    = this.backButton;
            this.modeButtons[0].nextSelectable[2]    = this.refreshButton;
            this.refreshButton.nextSelectable[0]     = this.modeButtons[0];
            this.refreshButton.nextSelectable[1]     = this.joinButtons[this.joinButtons.Length - 1];
            this.refreshButton.nextSelectable[3]     = this.joinButtons[0];
            this.refreshButton.nextSelectable[2]     = this.refreshButton;
            this.privacyButtons[0].nextSelectable[0] = this.joinButtons[0];
            this.privacyButtons[0].nextSelectable[1] = this.startLobbyButton;
            this.privacyButtons[0].nextSelectable[3] = this.maxPlayersSlider;
            this.privacyButtons[0].nextSelectable[2] = this.privacyButtons[1];
            this.privacyButtons[1].nextSelectable[0] = this.privacyButtons[0];
            this.privacyButtons[1].nextSelectable[1] = this.startLobbyButton;
            this.privacyButtons[1].nextSelectable[3] = this.maxPlayersSlider;
            this.privacyButtons[1].nextSelectable[2] = this.privacyButtons[2];
            this.privacyButtons[2].nextSelectable[0] = this.privacyButtons[1];
            this.privacyButtons[2].nextSelectable[1] = this.startLobbyButton;
            this.privacyButtons[2].nextSelectable[3] = this.maxPlayersSlider;
            this.privacyButtons[2].nextSelectable[2] = this.bodyRed;
            this.maxPlayersSlider.nextSelectable[1]  = this.privacyButtons[1];
            this.maxPlayersSlider.nextSelectable[3]  = this.spearsHitBox;
            this.spearsHitBox.nextSelectable[0]      = this.joinButtons[4];
            this.spearsHitBox.nextSelectable[1]      = this.maxPlayersSlider;
            this.spearsHitBox.nextSelectable[3]      = this.spearsHitBox;
            this.spearsHitBox.nextSelectable[2]      = this.bodyGreen;
            this.debugAllowBox.nextSelectable[0]     = this.joinButtons[5];
            this.debugAllowBox.nextSelectable[1]     = this.spearsHitBox;
            this.debugAllowBox.nextSelectable[3]     = this.startLobbyButton;
            this.debugAllowBox.nextSelectable[2]     = this.eyesRed;


            //Some Nice Music :)
            if (manager.musicPlayer != null)
            {
                manager.musicPlayer.MenuRequestsSong("NA_05 - Sparkles", 1.2f, 10f);
            }
        }
Пример #14
0
 /// <summary>
 /// Determines if this draw operation equals another.
 /// </summary>
 /// <param name="transform">The transform of the other draw operation.</param>
 /// <param name="brush">The fill of the other draw operation.</param>
 /// <param name="rect">The rectangle of the other draw operation.</param>
 /// <returns>True if the draw operations are the same, otherwise false.</returns>
 /// <remarks>
 /// The properties of the other draw operation are passed in as arguments to prevent
 /// allocation of a not-yet-constructed draw operation object.
 /// </remarks>
 public bool Equals(Matrix transform, IExperimentalAcrylicMaterial material, RoundedRect rect)
 {
     return(transform == Transform &&
            Equals(material, Material) &&
            rect.Equals(Rect));
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClipNode"/> class that represents a
 /// clip push.
 /// </summary>
 /// <param name="clip">The clip to push.</param>
 public ClipNode(RoundedRect clip)
 {
     Clip = clip;
 }
Пример #16
0
 public void PushClip(RoundedRect clip)
 {
     Canvas.Save();
     Canvas.ClipRoundRect(clip.ToSKRoundRect());
 }
Пример #17
0
        public override Task Rebuild()
        {
            using (RebuildLock())
            {
                using (new CenterAndHeightMaintainer(this))
                {
                    this.Children.Modify(list =>
                    {
                        list.Clear();
                    });

                    var brailleText = TextToEncode;
                    if (UseGrade2)
                    {
                        brailleText = BrailleGrade2.ConvertString(brailleText);
                    }

                    double    pointSize  = 18.5;
                    double    pointsToMm = 0.352778;
                    IObject3D textObject = new Object3D();
                    var       offest     = 0.0;

                    TypeFacePrinter textPrinter;
                    if (RenderAsBraille)
                    {
                        textPrinter = new TypeFacePrinter(brailleText, new StyledTypeFace(typeFace, pointSize));
                    }
                    else
                    {
                        textPrinter = new TypeFacePrinter(brailleText, new StyledTypeFace(ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono), pointSize));
                    }

                    foreach (var letter in brailleText.ToCharArray())
                    {
                        IObject3D       letterObject;
                        TypeFacePrinter letterPrinter;
                        if (RenderAsBraille)
                        {
                            letterPrinter = new TypeFacePrinter(letter.ToString(), new StyledTypeFace(typeFace, pointSize));
                            var scalledLetterPrinter = new VertexSourceApplyTransform(letterPrinter, Affine.NewScaling(pointsToMm));

                            // add all the spheres to letterObject
                            letterObject = new Object3D();

                            var vertexCount  = 0;
                            var positionSum  = Vector2.Zero;
                            var lastPosition = Vector2.Zero;
                            // find each dot outline and get it's center and place a sphere there
                            foreach (var vertex in scalledLetterPrinter.Vertices())
                            {
                                switch (vertex.command)
                                {
                                case Agg.ShapePath.FlagsAndCommand.Stop:
                                case Agg.ShapePath.FlagsAndCommand.EndPoly:
                                case Agg.ShapePath.FlagsAndCommand.FlagClose:
                                case Agg.ShapePath.FlagsAndCommand.MoveTo:
                                    if (vertexCount > 0)
                                    {
                                        var    center = positionSum / vertexCount;
                                        double radius = 1.44 / 2;                                                // (center - lastPosition).Length;
                                        var    sphere = new HalfSphereObject3D(radius * 2, 15)
                                        {
                                            Color = Color.LightBlue
                                        };
                                        sphere.Translate(center.X, center.Y);
                                        letterObject.Children.Add(sphere);
                                    }
                                    vertexCount = 0;
                                    positionSum = Vector2.Zero;
                                    break;

                                case Agg.ShapePath.FlagsAndCommand.Curve3:
                                case Agg.ShapePath.FlagsAndCommand.Curve4:
                                case Agg.ShapePath.FlagsAndCommand.LineTo:
                                    vertexCount++;
                                    lastPosition = vertex.position;
                                    positionSum += lastPosition;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            letterPrinter = new TypeFacePrinter(letter.ToString(), new StyledTypeFace(ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono), pointSize));
                            var scalledLetterPrinter = new VertexSourceApplyTransform(letterPrinter, Affine.NewScaling(pointsToMm));
                            letterObject = new Object3D()
                            {
                                Mesh  = VertexSourceToMesh.Extrude(scalledLetterPrinter, 1),
                                Color = Color.LightBlue
                            };
                        }

                        letterObject.Matrix = Matrix4X4.CreateTranslation(offest, 0, 0);
                        textObject.Children.Add(letterObject);

                        offest += letterPrinter.GetSize(letter.ToString()).X *pointsToMm;
                    }

                    // add a plate under the dots
                    var padding = .9 * pointSize * pointsToMm / 2;
                    var size    = textPrinter.LocalBounds * pointsToMm;

                    // make the base
                    var basePath = new VertexStorage();
                    basePath.MoveTo(0, 0);
                    basePath.LineTo(size.Width + padding, 0);
                    basePath.LineTo(size.Width + padding, size.Height + padding);
                    basePath.LineTo(padding, size.Height + padding);
                    basePath.LineTo(0, size.Height);

                    IObject3D basePlate = new Object3D()
                    {
                        Mesh = VertexSourceToMesh.Extrude(basePath, BaseHeight)
                    };

                    basePlate = new AlignObject3D(basePlate, FaceAlign.Top, textObject, FaceAlign.Bottom, 0, 0, .01);
                    basePlate = new AlignObject3D(basePlate, FaceAlign.Left | FaceAlign.Front,
                                                  size.Left - padding / 2,
                                                  size.Bottom - padding / 2);
                    this.Children.Add(basePlate);

                    basePlate.Matrix *= Matrix4X4.CreateRotationX(MathHelper.Tau / 4);

                    // add an optional chain hook
                    if (AddHook)
                    {
                        // x 10 to make it smoother
                        double        edgeWidth      = 3;
                        double        height         = basePlate.ZSize();
                        IVertexSource leftSideObject = new RoundedRect(0, 0, height / 2, height, 0)
                        {
                            ResolutionScale = 10
                        };

                        IVertexSource cicleObject = new Ellipse(0, 0, height / 2, height / 2)
                        {
                            ResolutionScale = 10
                        };

                        cicleObject = new Align2D(cicleObject, Side2D.Left | Side2D.Bottom, leftSideObject, Side2D.Left | Side2D.Bottom, -.01);
                        IVertexSource holeObject = new Ellipse(0, 0, height / 2 - edgeWidth, height / 2 - edgeWidth)
                        {
                            ResolutionScale = 10
                        };
                        holeObject = new SetCenter2D(holeObject, cicleObject.GetBounds().Center);

                        IVertexSource hookPath = leftSideObject.Plus(cicleObject);
                        hookPath = hookPath.Minus(holeObject);

                        IObject3D chainHook = new Object3D()
                        {
                            Mesh   = VertexSourceToMesh.Extrude(hookPath, BaseHeight),
                            Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 4)
                        };

                        chainHook = new AlignObject3D(chainHook, FaceAlign.Left | FaceAlign.Bottom | FaceAlign.Back, basePlate, FaceAlign.Right | FaceAlign.Bottom | FaceAlign.Back, -.01);

                        this.Children.Add(chainHook);
                    }

                    // add the object that is the dots
                    this.Children.Add(textObject);
                    textObject.Matrix *= Matrix4X4.CreateRotationX(MathHelper.Tau / 4);
                }
            }

            Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
            return(Task.CompletedTask);
        }
        public void roundedRect(double x, double y, double width, double height, double cornerRadius)
        {
            var rect = new RoundedRect
            {
                Rect = new RectangleF(f(x), f(y), f(x + width), f(y + height)),
                RadiusX = f(cornerRadius),
                RadiusY = f(cornerRadius)
            };

            _target.DrawRoundedRectangle(rect, _strokeBrush, _strokeWidth);
        }
 /// <summary>	
 ///  Creates an <see cref="SharpDX.Direct2D1.RoundedRectangleGeometry"/>. 	
 /// </summary>	
 /// <param name="factory">an instance of <see cref = "SharpDX.Direct2D1.Factory" /></param>
 /// <param name="roundedRectangle">The coordinates and corner radii of the rounded rectangle geometry.</param>
 public RoundedRectangleGeometry(Factory factory, RoundedRect roundedRectangle)
     : base(IntPtr.Zero)
 {
     factory.CreateRoundedRectangleGeometry(ref roundedRectangle, this);
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClipNode"/> class that represents a
 /// clip push.
 /// </summary>
 /// <param name="transform">The current transform.</param>
 /// <param name="clip">The clip to push.</param>
 public ClipNode(Matrix transform, RoundedRect clip)
 {
     Transform = transform;
     Clip      = clip;
 }
Пример #21
0
 /// <summary>	
 /// Draws the outline of the specified rounded rectangle.	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline.  </param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the rounded rectangle's outline. The default value is 1.0f.  </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawRoundedRectangle(RoundedRect roundedRect, Brush brush, float strokeWidth)
 {
     DrawRoundedRectangle(ref roundedRect, brush, strokeWidth, null);
 }
Пример #22
0
        public async Task SaveSheets()
        {
            await Task.Run((Func <Task>)(async() =>
            {
                currentlySaving = true;
                // first create images for all the parts
                foreach (var item in itemSource)
                {
                    var object3D = await item.CreateContent();

                    var loadedMeshGroups = object3D.VisibleMeshes().ToList();
                    if (loadedMeshGroups?.Count > 0)
                    {
                        AxisAlignedBoundingBox aabb = loadedMeshGroups[0].Mesh.GetAxisAlignedBoundingBox(loadedMeshGroups[0].WorldMatrix());

                        for (int i = 1; i < loadedMeshGroups.Count; i++)
                        {
                            aabb = AxisAlignedBoundingBox.Union(aabb, loadedMeshGroups[i].Mesh.GetAxisAlignedBoundingBox(loadedMeshGroups[i].WorldMatrix()));
                        }

                        RectangleDouble bounds2D = new RectangleDouble(aabb.minXYZ.X, aabb.minXYZ.Y, aabb.maxXYZ.X, aabb.maxXYZ.Y);
                        double widthInMM         = bounds2D.Width + PartMarginMM * 2;
                        double textSpaceMM       = 5;
                        double heightMM          = textSpaceMM + bounds2D.Height + PartMarginMM * 2;

                        TypeFacePrinter typeFacePrinter = new TypeFacePrinter(item.Name, 28, Vector2.Zero, Justification.Center, Baseline.BoundsCenter);
                        double sizeOfNameX   = typeFacePrinter.GetSize().X + PartMarginPixels * 2;
                        Vector2 sizeOfRender = new Vector2(widthInMM *PixelPerMM, heightMM *PixelPerMM);

                        ImageBuffer imageOfPart = new ImageBuffer((int)(Math.Max(sizeOfNameX, sizeOfRender.X)), (int)(sizeOfRender.Y));
                        typeFacePrinter.Origin  = new Vector2(imageOfPart.Width / 2, (textSpaceMM / 2) * PixelPerMM);

                        Graphics2D partGraphics2D = imageOfPart.NewGraphics2D();

                        RectangleDouble rectBounds = new RectangleDouble(0, 0, imageOfPart.Width, imageOfPart.Height);
                        double strokeWidth         = .5 * PixelPerMM;
                        rectBounds.Inflate(-strokeWidth / 2);
                        RoundedRect rect = new RoundedRect(rectBounds, PartMarginMM *PixelPerMM);
                        partGraphics2D.Render(rect, Color.LightGray);
                        Stroke rectOutline = new Stroke(rect, strokeWidth);
                        partGraphics2D.Render(rectOutline, Color.DarkGray);

                        foreach (var meshGroup in loadedMeshGroups)
                        {
                            PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, meshGroup.Mesh, meshGroup.WorldMatrix(), new Vector2(-bounds2D.Left + PartMarginMM, -bounds2D.Bottom + textSpaceMM + PartMarginMM), PixelPerMM, Color.Black);
                        }
                        partGraphics2D.Render(typeFacePrinter, Color.Black);

                        partImagesToPrint.Add(new PartImage(imageOfPart));
                    }

                    UpdateRemainingItems?.Invoke(this, new StringEventArgs(item.Name));
                }

                partImagesToPrint.Sort(BiggestToLittlestImages);

                PdfDocument document   = new PdfDocument();
                document.Info.Title    = "MatterHackers Parts Sheet";
                document.Info.Author   = "MatterHackers Inc.";
                document.Info.Subject  = "This is a list of the parts that are in a queue from MatterControl.";
                document.Info.Keywords = "MatterControl, STL, 3D Printing";

                int nextPartToPrintIndex = 0;
                int plateNumber          = 1;
                bool done = false;

                while (!done && nextPartToPrintIndex < partImagesToPrint.Count)
                {
                    PdfPage pdfPage = document.AddPage();
                    CreateOnePage(plateNumber++, ref nextPartToPrintIndex, pdfPage);
                }

                try
                {
                    // save the final document
                    document.Save(pathAndFileToSaveTo);

                    // Now try and open the document. This will launch whatever PDF viewer is on the system and ask it
                    // to show the file (at least on Windows).
                    Process.Start(pathAndFileToSaveTo);
                }
                catch (Exception)
                {
                }

                OnDoneSaving();
                currentlySaving = false;
            }));
        }
Пример #23
0
 /// <summary>	
 /// Draws the outline of the specified rounded rectangle using the specified stroke style.	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline.  </param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the rounded rectangle's outline. The default value is 1.0f.  </param>
 /// <param name="strokeStyle">The style of the rounded rectangle's stroke, or NULL to paint a solid stroke. The default value is NULL. </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawRoundedRectangle(RoundedRect roundedRect, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
 {
     DrawRoundedRectangle(ref roundedRect, brush, strokeWidth, strokeStyle);
 }
Пример #24
0
        private void DrawRectangle(Vector2 imagePosition)
        {
            RoundedRect rect = new RoundedRect(imagePosition.x - 20, imagePosition.y - 7, imagePosition.x + 20, imagePosition.y + 7, 3);

            graphics.Render(new Stroke(rect), RGBA_Bytes.Black);
        }
Пример #25
0
 /// <summary>	
 /// Paints the interior of the specified rounded rectangle.	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{FillRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="roundedRect">The dimensions of the rounded rectangle to paint, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the interior of the rounded rectangle. </param>
 /// <unmanaged>void ID2D1RenderTarget::FillRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush)</unmanaged>
 public void FillRoundedRectangle(RoundedRect roundedRect, Brush brush)
 {
     FillRoundedRectangle(ref roundedRect, brush);
 }
Пример #26
0
        /// <inheritdoc />
        public void DrawRectangle(IBrush brush, IPen pen, RoundedRect rrect, BoxShadows boxShadow = default)
        {
            var rc      = rrect.Rect.ToDirect2D();
            var rect    = rrect.Rect;
            var radiusX = Math.Max(rrect.RadiiTopLeft.X,
                                   Math.Max(rrect.RadiiTopRight.X, Math.Max(rrect.RadiiBottomRight.X, rrect.RadiiBottomLeft.X)));
            var radiusY = Math.Max(rrect.RadiiTopLeft.Y,
                                   Math.Max(rrect.RadiiTopRight.Y, Math.Max(rrect.RadiiBottomRight.Y, rrect.RadiiBottomLeft.Y)));
            var isRounded = !MathUtilities.IsZero(radiusX) || !MathUtilities.IsZero(radiusY);

            if (brush != null)
            {
                using (var b = CreateBrush(brush, rect.Size))
                {
                    if (b.PlatformBrush != null)
                    {
                        if (isRounded)
                        {
                            _deviceContext.FillRoundedRectangle(
                                new RoundedRectangle
                            {
                                Rect = new RawRectangleF(
                                    (float)rect.X,
                                    (float)rect.Y,
                                    (float)rect.Right,
                                    (float)rect.Bottom),
                                RadiusX = (float)radiusX,
                                RadiusY = (float)radiusY
                            },
                                b.PlatformBrush);
                        }
                        else
                        {
                            _deviceContext.FillRectangle(rc, b.PlatformBrush);
                        }
                    }
                }
            }

            if (pen?.Brush != null)
            {
                using (var wrapper = CreateBrush(pen.Brush, rect.Size))
                    using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext))
                    {
                        if (wrapper.PlatformBrush != null)
                        {
                            if (isRounded)
                            {
                                _deviceContext.DrawRoundedRectangle(
                                    new RoundedRectangle {
                                    Rect = rc, RadiusX = (float)radiusX, RadiusY = (float)radiusY
                                },
                                    wrapper.PlatformBrush,
                                    (float)pen.Thickness,
                                    d2dStroke);
                            }
                            else
                            {
                                _deviceContext.DrawRectangle(
                                    rc,
                                    wrapper.PlatformBrush,
                                    (float)pen.Thickness,
                                    d2dStroke);
                            }
                        }
                    }
            }
        }
Пример #27
0
        public void Rebuild(UndoBuffer undoBuffer)
        {
            using (RebuildLock())
            {
                var aabb = this.GetAxisAlignedBoundingBox();

                this.Children.Modify(list =>
                {
                    list.Clear();
                });

                var brailleLetter = new BrailleObject3D()
                {
                    TextToEncode = Letter.ToString(),
                    BaseHeight   = BaseHeight,
                };
                brailleLetter.Rebuild(null);
                this.Children.Add(brailleLetter);

                var textObject = new TextObject3D()
                {
                    PointSize   = 46,
                    Color       = Color.LightBlue,
                    NameToWrite = Letter.ToString(),
                    Height      = BaseHeight
                };

                textObject.Invalidate(new InvalidateArgs(textObject, InvalidateType.Properties, null));
                IObject3D letterObject = new RotateObject3D(textObject, MathHelper.Tau / 4);
                letterObject = new AlignObject3D(letterObject, FaceAlign.Bottom | FaceAlign.Front, brailleLetter, FaceAlign.Top | FaceAlign.Front, 0, 0, 3.5);
                letterObject = new SetCenterObject3D(letterObject, brailleLetter.GetCenter(), true, false, false);
                this.Children.Add(letterObject);

                var basePath = new RoundedRect(0, 0, 22, 34, 3)
                {
                    ResolutionScale = 10
                };

                IObject3D basePlate = new Object3D()
                {
                    Mesh   = VertexSourceToMesh.Extrude(basePath, BaseHeight),
                    Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 4)
                };

                basePlate = new AlignObject3D(basePlate, FaceAlign.Bottom | FaceAlign.Back, brailleLetter, FaceAlign.Bottom | FaceAlign.Back);
                basePlate = new SetCenterObject3D(basePlate, brailleLetter.GetCenter(), true, false, false);
                this.Children.Add(basePlate);

                IObject3D underline = new CubeObject3D(basePlate.XSize(), .2, 1);
                underline = new AlignObject3D(underline, FaceAlign.Bottom, brailleLetter, FaceAlign.Top);
                underline = new AlignObject3D(underline, FaceAlign.Back | FaceAlign.Left, basePlate, FaceAlign.Front | FaceAlign.Left, 0, .01);
                this.Children.Add(underline);

                if (aabb.ZSize > 0)
                {
                    // If the part was already created and at a height, maintain the height.
                    PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
                }
            }

            Invalidate(new InvalidateArgs(this, InvalidateType.Content));
        }
Пример #28
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            double fontHeight = internalTextWidget.Printer.TypeFaceStyle.EmSizeInPixels;

            if (Selecting &&
                SelectionIndexToStartBefore != CharIndexToInsertBefore)
            {
                Vector2 selectPosition = internalTextWidget.Printer.GetOffsetLeftOfCharacterIndex(SelectionIndexToStartBefore);

                // for each selected line draw a rect for the chars of that line
                if (selectPosition.y == InsertBarPosition.y)
                {
                    RectangleDouble bar = new RectangleDouble(Math.Ceiling(selectPosition.x),
                                                              Math.Ceiling(internalTextWidget.Height + selectPosition.y),
                                                              Math.Ceiling(InsertBarPosition.x + 1),
                                                              Math.Ceiling(internalTextWidget.Height + InsertBarPosition.y - fontHeight));

                    RoundedRect selectCursorRect = new RoundedRect(bar, 0);
                    graphics2D.Render(selectCursorRect, this.highlightColor);
                }
                else
                {
                    int     firstCharToHighlight = Math.Min(CharIndexToInsertBefore, SelectionIndexToStartBefore);
                    int     lastCharToHighlight  = Math.Max(CharIndexToInsertBefore, SelectionIndexToStartBefore);
                    int     lineStart            = firstCharToHighlight;
                    Vector2 lineStartPos         = internalTextWidget.Printer.GetOffsetLeftOfCharacterIndex(lineStart);
                    int     lineEnd    = lineStart + 1;
                    Vector2 lineEndPos = internalTextWidget.Printer.GetOffsetLeftOfCharacterIndex(lineEnd);
                    if (lineEndPos.y != lineStartPos.y)
                    {
                        // we are starting on a '\n', adjust so we will show the cr at the end of the line
                        lineEndPos = lineStartPos;
                    }
                    bool firstCharOfLine = false;
                    for (int i = lineEnd; i < lastCharToHighlight + 1; i++)
                    {
                        Vector2 nextPos = internalTextWidget.Printer.GetOffsetLeftOfCharacterIndex(i);
                        if (firstCharOfLine)
                        {
                            if (lineEndPos.y != lineStartPos.y)
                            {
                                // we are starting on a '\n', adjust so we will show the cr at the end of the line
                                lineEndPos = lineStartPos;
                            }
                            firstCharOfLine = false;
                        }
                        if (nextPos.y != lineStartPos.y)
                        {
                            if (lineEndPos.x == lineStartPos.x)
                            {
                                lineEndPos.x += Printer.TypeFaceStyle.GetAdvanceForCharacter(' ');
                            }
                            RectangleDouble bar = new RectangleDouble(Math.Ceiling(lineStartPos.x),
                                                                      Math.Ceiling(internalTextWidget.Height + lineStartPos.y),
                                                                      Math.Ceiling(lineEndPos.x + 1),
                                                                      Math.Ceiling(internalTextWidget.Height + lineEndPos.y - fontHeight));

                            RoundedRect selectCursorRect = new RoundedRect(bar, 0);
                            graphics2D.Render(selectCursorRect, this.highlightColor);
                            lineStartPos    = nextPos;
                            firstCharOfLine = true;
                        }
                        else
                        {
                            lineEndPos = nextPos;
                        }
                    }
                    if (lineEndPos.x != lineStartPos.x)
                    {
                        RectangleDouble bar = new RectangleDouble(Math.Ceiling(lineStartPos.x),
                                                                  Math.Ceiling(internalTextWidget.Height + lineStartPos.y),
                                                                  Math.Ceiling(lineEndPos.x + 1),
                                                                  Math.Ceiling(internalTextWidget.Height + lineEndPos.y - fontHeight));

                        RoundedRect selectCursorRect = new RoundedRect(bar, 0);
                        graphics2D.Render(selectCursorRect, this.highlightColor);
                    }
                }
            }

            if (this.Focused && BarIsShowing)
            {
                double xFraction = graphics2D.GetTransform().tx;
                xFraction = xFraction - (int)xFraction;
                RectangleDouble bar2 = new RectangleDouble(Math.Ceiling(InsertBarPosition.x) - xFraction,
                                                           Math.Ceiling(internalTextWidget.Height + InsertBarPosition.y - fontHeight),
                                                           Math.Ceiling(InsertBarPosition.x + 1) - xFraction,
                                                           Math.Ceiling(internalTextWidget.Height + InsertBarPosition.y));
                RoundedRect cursorRect = new RoundedRect(bar2, 0);
                graphics2D.Render(cursorRect, this.cursorColor);
            }

            RectangleDouble boundsPlusPoint5 = LocalBounds;

            boundsPlusPoint5.Inflate(-.5);
            RoundedRect borderRect = new RoundedRect(boundsPlusPoint5, 0);
            Stroke      borderLine = new Stroke(borderRect);

            base.OnDraw(graphics2D);
        }
Пример #29
0
        //private void CreateProductDataWidgets(PrinterSettings printerSettings, ProductSkuData product)
        private void CreateProductDataWidgets(ProductSkuData product)
        {
            var row = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Margin  = new BorderDouble(top: theme.DefaultContainerPadding)
            };

            productDataContainer.AddChild(row);

            var image = new ImageBuffer(150, 10);

            row.AddChild(new ImageWidget(image)
            {
                Margin  = new BorderDouble(right: theme.DefaultContainerPadding),
                VAnchor = VAnchor.Top
            });

            WebCache.RetrieveImageAsync(image, product.FeaturedImage.ImageUrl, scaleToImageX: true);

            var descriptionBackground = new GuiWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit | VAnchor.Top,
                Padding = theme.DefaultContainerPadding
            };

            var description = new MarkdownWidget(theme)
            {
                MinimumSize = new VectorMath.Vector2(50, 0),
                HAnchor     = HAnchor.Stretch,
                VAnchor     = VAnchor.Fit,
                AutoScroll  = false,
                Markdown    = product.ProductDescription.Trim()
            };

            descriptionBackground.AddChild(description);
            descriptionBackground.BeforeDraw += (s, e) =>
            {
                var rect = new RoundedRect(descriptionBackground.LocalBounds, 3);
                e.Graphics2D.Render(rect, theme.SlightShade);
            };

            row.AddChild(descriptionBackground);

            if (this.ShowProducts)
            {
                var padding = theme.DefaultContainerPadding;

                var addonsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom)
                {
                    Padding = new BorderDouble(padding, padding, padding, 0),
                    HAnchor = HAnchor.Stretch
                };

                var addonsSection = new SectionWidget("Upgrades and Accessories", addonsColumn, theme);
                productDataContainer.AddChild(addonsSection);
                theme.ApplyBoxStyle(addonsSection);
                addonsSection.Margin = addonsSection.Margin.Clone(left: 0);

                foreach (var item in product.ProductListing.AddOns)
                {
                    var addOnRow = new AddOnRow(item.AddOnTitle, theme, null, item.Icon)
                    {
                        HAnchor = HAnchor.Stretch,
                        Cursor  = Cursors.Hand
                    };

                    foreach (var child in addOnRow.Children)
                    {
                        child.Selectable = false;
                    }

                    addOnRow.Click += (s, e) =>
                    {
                        ApplicationController.LaunchBrowser($"https://www.matterhackers.com/store/l/{item.AddOnListingReference}/sk/{item.AddOnSkuReference}");
                    };

                    addonsColumn.AddChild(addOnRow);
                }
            }

            //if (false)
            //{
            //	var settingsPanel = new GuiWidget()
            //	{
            //		HAnchor = HAnchor.Stretch,
            //		VAnchor = VAnchor.Stretch,
            //		MinimumSize = new VectorMath.Vector2(20, 20),
            //		DebugShowBounds = true
            //	};

            //	settingsPanel.Load += (s, e) =>
            //	{
            //		var printer = new PrinterConfig(printerSettings);

            //		var settingsContext = new SettingsContext(
            //			printer,
            //			null,
            //			NamedSettingsLayers.All);

            //		settingsPanel.AddChild(
            //			new ConfigurePrinterWidget(settingsContext, printer, theme)
            //			{
            //				HAnchor = HAnchor.Stretch,
            //				VAnchor = VAnchor.Stretch,
            //			});
            //	};

            //	this.AddChild(new SectionWidget("Settings", settingsPanel, theme, expanded: false, setContentVAnchor: false)
            //	{
            //		VAnchor = VAnchor.Stretch
            //	});
            //}
        }
Пример #30
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            {
                ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
                Graphics2D  subGraphics2D   = widgetsSubImage.NewGraphics2D();

                subGraphics2D.Clear(new Color(255, 255, 255));
                for (int y = 0; y < MomsGame.GetHeight(); y++)
                {
                    for (int x = 0; x < MomsGame.GetWidth(); x++)
                    {
                        DrawCard(subGraphics2D, x, y);
                    }
                }

                String whatToDo       = "Select any open space marked with an 'O'";
                Color  backFillCollor = new Color(0xe1, 0xe0, 0xf6);

                if (MomsGame.GetWaitingForKing())
                {
                    backFillCollor = new Color(0xf8, 0x89, 0x78);
                    whatToDo       = "Select a King for the hole";
                }
                else if (MomsGame.IsSolved())
                {
                    backFillCollor = new Color(0xf8, 0x89, 0x78);
                    whatToDo       = "You win!";
                }
                else if (!MomsGame.MoveAvailable())
                {
                    backFillCollor = new Color(0xf8, 0x89, 0x78);
                    whatToDo       = "No more moves! Shuffle to continue.";
                }

                if (whatToDo != null)
                {
                    TextWidget      stringToDraw = new TextWidget(whatToDo, 12);
                    RectangleDouble Size         = stringToDraw.Printer.LocalBounds;
                    double          TextX        = m_BoardX + CARD_WIDTH * 4;
                    double          TextY        = m_BoardY - 34;
                    RoundedRect     BackFill     = new RoundedRect(Size.Left - 6, Size.Bottom - 3, Size.Right + 6, Size.Top + 6, 3);
                    Stroke          BackBorder   = new Stroke(BackFill);
                    BackBorder.width(2);

                    subGraphics2D.SetTransform(Affine.NewTranslation(TextX, TextY));
                    subGraphics2D.Render(BackFill, backFillCollor);
                    subGraphics2D.Render(BackBorder, new Color(0, 0, 0));
                    subGraphics2D.Render(stringToDraw.Printer, new Color(0, 0, 0));
                }

                String ShufflesString;
                ShufflesString  = "Number of shuffles so far = ";
                ShufflesString += MomsGame.GetNumShuffles().ToString();

                TextWidget shuffelStringToDraw = new TextWidget(ShufflesString, 12);
                subGraphics2D.SetTransform(Affine.NewTranslation(m_BoardX, 350));
                subGraphics2D.Render(shuffelStringToDraw.Printer, new Color(0, 0, 0));

                subGraphics2D.SetTransform(Affine.NewIdentity());
            }
            base.OnDraw(graphics2D);
        }
Пример #31
0
 public void DrawRectangle(IBrush brush, IPen pen, RoundedRect rect, BoxShadows boxShadow = default)
 {
 }
Пример #32
0
        /// <inheritdoc />
        public void DrawRectangle(IBrush brush, IPen pen, RoundedRect rect, BoxShadows boxShadows = default)
        {
            if (rect.Rect.Height <= 0 || rect.Rect.Width <= 0)
            {
                return;
            }
            // Arbitrary chosen values
            // On OSX Skia breaks OpenGL context when asked to draw, e. g. (0, 0, 623, 6666600) rect
            if (rect.Rect.Height > 8192 || rect.Rect.Width > 8192)
            {
                boxShadows = default;
            }

            var rc            = rect.Rect.ToSKRect();
            var isRounded     = rect.IsRounded;
            var needRoundRect = rect.IsRounded || (boxShadows.HasInsetShadows);

            using var skRoundRect = needRoundRect ? new SKRoundRect() : null;
            if (needRoundRect)
            {
                skRoundRect.SetRectRadii(rc,
                                         new[]
                {
                    rect.RadiiTopLeft.ToSKPoint(), rect.RadiiTopRight.ToSKPoint(),
                    rect.RadiiBottomRight.ToSKPoint(), rect.RadiiBottomLeft.ToSKPoint(),
                });
            }

            foreach (var boxShadow in boxShadows)
            {
                if (!boxShadow.IsEmpty && !boxShadow.IsInset)
                {
                    using (var shadow = BoxShadowFilter.Create(_boxShadowPaint, boxShadow, _currentOpacity))
                    {
                        var spread = (float)boxShadow.Spread;
                        if (boxShadow.IsInset)
                        {
                            spread = -spread;
                        }

                        Canvas.Save();
                        if (isRounded)
                        {
                            using var shadowRect = new SKRoundRect(skRoundRect);
                            if (spread != 0)
                            {
                                shadowRect.Inflate(spread, spread);
                            }
                            Canvas.ClipRoundRect(skRoundRect,
                                                 shadow.ClipOperation, true);

                            var oldTransform = Transform;
                            Transform = oldTransform * Matrix.CreateTranslation(boxShadow.OffsetX, boxShadow.OffsetY);
                            Canvas.DrawRoundRect(shadowRect, shadow.Paint);
                            Transform = oldTransform;
                        }
                        else
                        {
                            var shadowRect = rc;
                            if (spread != 0)
                            {
                                shadowRect.Inflate(spread, spread);
                            }
                            Canvas.ClipRect(rc, shadow.ClipOperation);
                            var oldTransform = Transform;
                            Transform = oldTransform * Matrix.CreateTranslation(boxShadow.OffsetX, boxShadow.OffsetY);
                            Canvas.DrawRect(shadowRect, shadow.Paint);
                            Transform = oldTransform;
                        }

                        Canvas.Restore();
                    }
                }
            }

            if (brush != null)
            {
                using (var paint = CreatePaint(_fillPaint, brush, rect.Rect))
                {
                    if (isRounded)
                    {
                        Canvas.DrawRoundRect(skRoundRect, paint.Paint);
                    }
                    else
                    {
                        Canvas.DrawRect(rc, paint.Paint);
                    }
                }
            }

            foreach (var boxShadow in boxShadows)
            {
                if (!boxShadow.IsEmpty && boxShadow.IsInset)
                {
                    using (var shadow = BoxShadowFilter.Create(_boxShadowPaint, boxShadow, _currentOpacity))
                    {
                        var spread    = (float)boxShadow.Spread;
                        var offsetX   = (float)boxShadow.OffsetX;
                        var offsetY   = (float)boxShadow.OffsetY;
                        var outerRect = AreaCastingShadowInHole(rc, (float)boxShadow.Blur, spread, offsetX, offsetY);

                        Canvas.Save();
                        using var shadowRect = new SKRoundRect(skRoundRect);
                        if (spread != 0)
                        {
                            shadowRect.Deflate(spread, spread);
                        }
                        Canvas.ClipRoundRect(skRoundRect,
                                             shadow.ClipOperation, true);

                        var oldTransform = Transform;
                        Transform = oldTransform * Matrix.CreateTranslation(boxShadow.OffsetX, boxShadow.OffsetY);
                        using (var outerRRect = new SKRoundRect(outerRect))
                            Canvas.DrawRoundRectDifference(outerRRect, shadowRect, shadow.Paint);
                        Transform = oldTransform;
                        Canvas.Restore();
                    }
                }
            }

            if (pen?.Brush != null)
            {
                using (var paint = CreatePaint(_strokePaint, pen, rect.Rect))
                {
                    if (paint.Paint is object)
                    {
                        if (isRounded)
                        {
                            Canvas.DrawRoundRect(skRoundRect, paint.Paint);
                        }
                        else
                        {
                            Canvas.DrawRect(rc, paint.Paint);
                        }
                    }
                }
            }
        }
Пример #33
0
        void MainWindow_Paint(object sender, PaintEventArgs e)
        {
            this._renderTarget.BeginDraw();
            this._renderTarget.Clear(Color.FromARGB(Colors.Blue, 1));

            PointF center = new PointF(ClientSize.Width / 2, ClientSize.Height / 2);
            this._renderTarget.Transform = Matrix3x2.Rotation(_angle, center);

            RoundedRect rr = new RoundedRect(new RectF(30, 30, ClientSize.Width - 60, ClientSize.Height - 60), ClientSize.Width / 2.5f, ClientSize.Height / 2.5f);
            this._renderTarget.FillRoundedRect(RectBrush, rr);
            this._renderTarget.DrawRoundedRect(_strokeBrush, 5, _strokeStyle, rr);

            Ellipse ellipse = new Ellipse(ClientSize.Width / 2, ClientSize.Height / 2, ClientSize.Width / 4, ClientSize.Height / 4);
            using (EllipseGeometry eg = this._factory.CreateEllipseGeometry(ellipse))
            {
                using (Brush b = CreateEllipseBrush(ellipse))
                {
                    this._renderTarget.FillGeometry(b, eg);
                    this._renderTarget.DrawGeometry(_strokeBrush, 5, _strokeStyle, eg);
                }
            }
            RectF textBounds = new RectF(0, 0, ClientSize.Width, ClientSize.Height);

            this._renderTarget.DrawText("Hello, world!", _textFormat, textBounds, _strokeBrush, DrawTextOptions.None, MeasuringMode.Natural);

            this._renderTarget.DrawLine(_strokeBrush, 5, _strokeStyle, new PointF(0, 0), new PointF(ClientSize.Width, ClientSize.Height));

            this._renderTarget.EndDraw();
        }
Пример #34
0
    public TeamCol(Team team)
    {
        this.team = team;

        label = new DualLabel(TOFonts.MEDIUM_BOLD,team.name.ToUpper());
        label.alpha = 0.5f;
        label.scale = 1.5f;
        AddChild(label);

        bool isNone = team == PlayerManager.Team_None;

        bgRect = new RoundedRect(WIDTH,HEIGHT,!isNone);
        AddChild(bgRect);

        if(isNone)
        {
            bgRect.width -= 25;
            bgRect.alpha = 0.2f;
        }

        label.mainLabel.color = team.color;
        bgRect.color = team.color;
    }
Пример #35
0
        public SteamMultiplayerMenu(ProcessManager manager, bool shouldCreateLobby = false) : base(manager, ProcessManager.ProcessID.MainMenu)
        {
            if (shouldCreateLobby)
            {
                MonklandSteamManager.instance.CreateLobby();
            }

            #region UI ELEMENTS SIZE DEFINITION

            float resOffset = (1366 - manager.rainWorld.screenSize.x) / 2; // shift everything to the right depending on the resolution. 1/2 of the diff with the max resolution.

            float screenWidth  = manager.rainWorld.screenSize.x;
            float screenHeight = manager.rainWorld.screenSize.y;
            // initialize some dynamic sizes and positions for UI elements.
            // player list and multiplayer settings have the same size no matter what the resolution.
            // the room chat adjusts to fill all the middle space
            float panelGutter = 15;                                                                             // gap width between the panels

            float playerListWidth                = 200;                                                         // constant
            float multiplayerSettingsWidth       = 300;                                                         // constant
            float multiplayerSettingsSliderWidth = multiplayerSettingsWidth - 115;                              // constant
            float roomChatWidth = screenWidth - (playerListWidth + multiplayerSettingsWidth + panelGutter * 4); // depends on resolution

            float playerListPositionX                = panelGutter;                                             // position depending on size
            float multiplayerSettingsPositionX       = screenWidth - (multiplayerSettingsWidth + panelGutter);  // position depending on screen width
            float multiplayerSettingsSliderPositionX = multiplayerSettingsPositionX + 10;                       // constant
            float roomChatPositionX = playerListWidth + panelGutter * 2;                                        // position depending on player list width

            float controlButtonSpaceHeight = 100;                                                               // constant
            float panelHeight    = screenHeight - (controlButtonSpaceHeight + panelGutter * 2);                 // leaving a space for control buttons
            float panelPositionY = controlButtonSpaceHeight;                                                    // constant

            #endregion UI ELEMENTS SIZE DEFINITION

            this.blackFade     = 1f;
            this.lastBlackFade = 1f;
            this.pages.Add(new Page(this, null, "main", 0));
            //this.scene = new InteractiveMenuScene( this, this.pages[0], MenuScene.SceneID.Landscape_SU );
            //this.pages[0].subObjects.Add( this.scene );
            this.darkSprite = new FSprite("pixel", true)
            {
                color   = new Color(0f, 0f, 0f),
                anchorX = 0f,
                anchorY = 0f,
                scaleX  = screenWidth,
                scaleY  = screenHeight,
                x       = screenWidth / 2f,
                y       = screenHeight / 2f,
                alpha   = 0.85f
            };
            this.pages[0].Container.AddChild(this.darkSprite);
            this.blackFadeSprite = new FSprite("Futile_White", true)
            {
                scaleX = 87.5f,
                scaleY = 50f,
                x      = screenWidth / 2f,
                y      = screenHeight / 2f,
                color  = new Color(0f, 0f, 0f)
            };
            Futile.stage.AddChild(this.blackFadeSprite);

            //Multiplayer Settings Box
            colorBox = new RoundedRect(this, this.pages[0], new Vector2(resOffset + multiplayerSettingsPositionX, panelPositionY), new Vector2(multiplayerSettingsWidth, panelHeight), false);
            this.pages[0].subObjects.Add(colorBox);

            //Settings Label
            settingsLabel = new FLabel("font", "Multiplayer Settings");
            settingsLabel.SetPosition(new Vector2(multiplayerSettingsPositionX + 70.01f, screenHeight - 60.01f));
            Futile.stage.AddChild(this.settingsLabel);

            //Body Color Label
            bodyLabel = new FLabel("font", "Body Color");
            bodyLabel.SetPosition(new Vector2(multiplayerSettingsPositionX + 70.01f, screenHeight - 90.01f));
            Futile.stage.AddChild(this.bodyLabel);

            //Red Slider
            bodyRed                       = new HorizontalSlider(this, this.pages[0], "Red", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 130), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)(-1), false);
            bodyRed.floatValue            = MonklandSteamManager.bodyColor.r;
            bodyRed.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyRed);
            //Green Slider
            bodyGreen                       = new HorizontalSlider(this, this.pages[0], "Green", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 170), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)(-1), false);
            bodyGreen.floatValue            = MonklandSteamManager.bodyColor.g;
            bodyGreen.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyGreen);
            //Blue Slider
            bodyBlue                       = new HorizontalSlider(this, this.pages[0], "Blue", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 210), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)(-1), false);
            bodyBlue.floatValue            = MonklandSteamManager.bodyColor.b;
            bodyBlue.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyBlue);

            //Eye Color Label
            eyesLabel = new FLabel("font", "Eye Color");
            eyesLabel.SetPosition(new Vector2(multiplayerSettingsPositionX + 70.01f, screenHeight - 240.01f));
            Futile.stage.AddChild(this.eyesLabel);

            //Red Slider
            eyesRed            = new HorizontalSlider(this, this.pages[0], "Red ", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 280), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)(-1), false);
            eyesRed.floatValue = MonklandSteamManager.eyeColor.r;
            this.pages[0].subObjects.Add(this.eyesRed);
            //Green Slider
            eyesGreen            = new HorizontalSlider(this, this.pages[0], "Green ", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 320), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)(-1), false);
            eyesGreen.floatValue = MonklandSteamManager.eyeColor.g;
            this.pages[0].subObjects.Add(this.eyesGreen);
            //Blue Slider
            eyesBlue            = new HorizontalSlider(this, this.pages[0], "Blue ", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 360), new Vector2(multiplayerSettingsSliderWidth, 30), (Slider.SliderID)(-1), false);
            eyesBlue.floatValue = MonklandSteamManager.eyeColor.b;
            this.pages[0].subObjects.Add(this.eyesBlue);

            //Slugcat Eyes Sprite
            eyes           = new FSprite("FoodCircleB", true);
            eyes.scaleX    = 1f;
            eyes.scaleY    = 1.1f;
            eyes.color     = new Color(0, 0, 0);
            eyes.x         = multiplayerSettingsPositionX + 130;
            eyes.y         = manager.rainWorld.screenSize.y - 236;
            eyes.isVisible = true;
            this.pages[0].Container.AddChild(this.eyes);

            //Slugcat Sprite
            slugcat           = new FSprite("slugcatSleeping", true);
            slugcat.scaleX    = 1f;
            slugcat.scaleY    = 1f;
            slugcat.color     = new Color(1f, 1f, 1f);
            slugcat.x         = multiplayerSettingsPositionX + 136;
            slugcat.y         = manager.rainWorld.screenSize.y - 235;
            slugcat.isVisible = true;
            this.pages[0].Container.AddChild(this.slugcat);

            //Debug Mode checkbox
            this.debugCheckBox = new CheckBox(this, this.pages[0], this, new Vector2(resOffset + multiplayerSettingsSliderPositionX + 120f, screenHeight - 400f), 120f, "Debug Mode", "DEBUG");
            this.pages[0].subObjects.Add(this.debugCheckBox);

            //Slugcat Buttons
            this.slugcatButtons    = new SelectOneButton[3];
            this.slugcatButtons[0] = new SelectOneButton(this, this.pages[0], base.Translate("SURVIOR"), "Slugcat", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 445f), new Vector2(110f, 30f), this.slugcatButtons, 0);
            this.pages[0].subObjects.Add(this.slugcatButtons[0]);
            this.slugcatButtons[1] = new SelectOneButton(this, this.pages[0], base.Translate("MONK"), "Slugcat", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 490f), new Vector2(110f, 30f), this.slugcatButtons, 1);
            this.pages[0].subObjects.Add(this.slugcatButtons[1]);
            this.slugcatButtons[2] = new SelectOneButton(this, this.pages[0], base.Translate("HUNTER"), "Slugcat", new Vector2(resOffset + multiplayerSettingsSliderPositionX, screenHeight - 535f), new Vector2(110f, 30f), this.slugcatButtons, 2);
            this.pages[0].subObjects.Add(this.slugcatButtons[2]);

            //Back button
            this.backButton = new SimpleButton(this, this.pages[0], base.Translate("BACK"), "EXIT", new Vector2(resOffset + 15f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.backButton);

            //Start Game button
            this.startGameButton = new SimpleButton(this, this.pages[0], "Start Game", "STARTGAME", new Vector2(resOffset + screenWidth - 125, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.startGameButton);

            //Ready Up button
            this.readyUpButton = new SimpleButton(this, this.pages[0], "Ready UP", "READYUP", new Vector2(resOffset + screenWidth - 250, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.readyUpButton);

            //Multiplayer Chat
            this.gameChat = new MultiplayerChat(this, this.pages[0], new Vector2(resOffset + roomChatPositionX, panelPositionY), new Vector2(roomChatWidth, panelHeight));
            this.pages[0].subObjects.Add(this.gameChat);

            //Invite menu
            playerList = new MultiplayerPlayerList(this, this.pages[0], new Vector2(resOffset + playerListPositionX, panelPositionY), new Vector2(playerListWidth, panelHeight), new Vector2(playerListWidth - 20, playerListWidth - 20));
            this.pages[0].subObjects.Add(this.playerList);

            //Controller Combatability
            this.bodyRed.nextSelectable[1]         = this.readyUpButton;
            this.bodyRed.nextSelectable[3]         = this.bodyGreen;
            this.bodyGreen.nextSelectable[1]       = this.bodyRed;
            this.bodyGreen.nextSelectable[3]       = this.bodyBlue;
            this.bodyBlue.nextSelectable[1]        = this.bodyGreen;
            this.bodyBlue.nextSelectable[3]        = this.eyesRed;
            this.eyesRed.nextSelectable[1]         = this.bodyBlue;
            this.eyesRed.nextSelectable[3]         = this.eyesGreen;
            this.eyesGreen.nextSelectable[1]       = this.eyesRed;
            this.eyesGreen.nextSelectable[3]       = this.eyesBlue;
            this.eyesBlue.nextSelectable[1]        = this.eyesGreen;
            this.eyesBlue.nextSelectable[3]        = this.debugCheckBox;
            this.debugCheckBox.nextSelectable[1]   = this.eyesBlue;
            this.debugCheckBox.nextSelectable[3]   = this.readyUpButton;
            this.readyUpButton.nextSelectable[0]   = this.backButton;
            this.readyUpButton.nextSelectable[1]   = this.debugCheckBox;
            this.readyUpButton.nextSelectable[2]   = this.startGameButton;
            this.readyUpButton.nextSelectable[3]   = this.bodyRed;
            this.startGameButton.nextSelectable[0] = this.readyUpButton;
            this.startGameButton.nextSelectable[1] = this.eyesBlue;
            this.startGameButton.nextSelectable[2] = this.backButton;
            this.startGameButton.nextSelectable[3] = this.bodyRed;
            this.backButton.nextSelectable[0]      = this.startGameButton;
            this.backButton.nextSelectable[2]      = this.readyUpButton;
            this.backButton.nextSelectable[1]      = this.bodyRed;
            this.backButton.nextSelectable[3]      = this.eyesBlue;

            //Some Nice Music :)
            if (manager.musicPlayer != null)
            {
                manager.musicPlayer.MenuRequestsSong("NA_05 - Sparkles", 1.2f, 10f);
            }

            //Fix Label pixelperfect
            foreach (MenuObject o in this.pages[0].subObjects)
            {
                if (o is MenuLabel l)
                {
                    l.pos += new Vector2(0.01f, 0.01f);
                }
            }
        }
Пример #36
0
 public void PushClip(RoundedRect clip)
 {
 }
        public SteamMultiplayerMenu(ProcessManager manager, bool shouldCreateLobby = false) : base(manager, ProcessManager.ProcessID.MainMenu)
        {
            if (shouldCreateLobby)
            {
                MonklandSteamManager.instance.CreateLobby();
            }

            this.blackFade     = 1f;
            this.lastBlackFade = 1f;
            this.pages.Add(new Page(this, null, "main", 0));
            //this.scene = new InteractiveMenuScene( this, this.pages[0], MenuScene.SceneID.Landscape_SU );
            //this.pages[0].subObjects.Add( this.scene );
            this.darkSprite         = new FSprite("pixel", true);
            this.darkSprite.color   = new Color(0f, 0f, 0f);
            this.darkSprite.anchorX = 0f;
            this.darkSprite.anchorY = 0f;
            this.darkSprite.scaleX  = 1368f;
            this.darkSprite.scaleY  = 770f;
            this.darkSprite.x       = -1f;
            this.darkSprite.y       = -1f;
            this.darkSprite.alpha   = 0.85f;
            this.pages[0].Container.AddChild(this.darkSprite);
            this.blackFadeSprite        = new FSprite("Futile_White", true);
            this.blackFadeSprite.scaleX = 87.5f;
            this.gameStarting           = false;
            this.blackFadeSprite.scaleY = 50f;
            this.blackFadeSprite.x      = manager.rainWorld.screenSize.x / 2f;
            this.blackFadeSprite.y      = manager.rainWorld.screenSize.y / 2f;
            this.blackFadeSprite.color  = new Color(0f, 0f, 0f);
            Futile.stage.AddChild(this.blackFadeSprite);

            //Multiplayer Settings Box
            colorBox = new RoundedRect(this, this.pages[0], new Vector2(940, 125), new Vector2(400, 600), false);
            this.pages[0].subObjects.Add(colorBox);

            //Settings Label
            settingsLabel = new FLabel("font", "Multiplayer Settings");
            settingsLabel.SetPosition(new Vector2(1140, manager.rainWorld.screenSize.y - 60));
            Futile.stage.AddChild(this.settingsLabel);

            //Body Color Label
            bodyLabel = new FLabel("font", "Body Color");
            bodyLabel.SetPosition(new Vector2(1140, manager.rainWorld.screenSize.y - 90));
            Futile.stage.AddChild(this.bodyLabel);

            //Red Slider
            bodyRed                       = new HorizontalSlider(this, this.pages[0], "Red", new Vector2(960, manager.rainWorld.screenSize.y - 130), new Vector2(255, 30), (Slider.SliderID)patch_Slider.SliderID.BodyRed, false);
            bodyRed.floatValue            = 1f;
            bodyRed.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyRed);
            //Green Slider
            bodyGreen                       = new HorizontalSlider(this, this.pages[0], "Green", new Vector2(960, manager.rainWorld.screenSize.y - 170), new Vector2(255, 30), (Slider.SliderID)patch_Slider.SliderID.BodyGreen, false);
            bodyGreen.floatValue            = 1f;
            bodyGreen.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyGreen);
            //Blue Slider
            bodyBlue                       = new HorizontalSlider(this, this.pages[0], "Blue", new Vector2(960, manager.rainWorld.screenSize.y - 210), new Vector2(255, 30), (Slider.SliderID)patch_Slider.SliderID.BodyBlue, false);
            bodyBlue.floatValue            = 1f;
            bodyBlue.buttonBehav.greyedOut = false;
            this.pages[0].subObjects.Add(this.bodyBlue);

            //Eye Color Label
            eyesLabel = new FLabel("font", "Eye Color");
            eyesLabel.SetPosition(new Vector2(1140, manager.rainWorld.screenSize.y - 235));
            Futile.stage.AddChild(this.eyesLabel);

            //Red Slider
            eyesRed            = new HorizontalSlider(this, this.pages[0], "Red ", new Vector2(960, manager.rainWorld.screenSize.y - 280), new Vector2(255, 30), (Slider.SliderID)patch_Slider.SliderID.EyesRed, false);
            eyesRed.floatValue = 0f;
            this.pages[0].subObjects.Add(this.eyesRed);
            //Green Slider
            eyesGreen            = new HorizontalSlider(this, this.pages[0], "Green ", new Vector2(960, manager.rainWorld.screenSize.y - 320), new Vector2(255, 30), (Slider.SliderID)patch_Slider.SliderID.EyesGreen, false);
            eyesGreen.floatValue = 0f;
            this.pages[0].subObjects.Add(this.eyesGreen);
            //Blue Slider
            eyesBlue            = new HorizontalSlider(this, this.pages[0], "Blue ", new Vector2(960, manager.rainWorld.screenSize.y - 360), new Vector2(255, 30), (Slider.SliderID)patch_Slider.SliderID.EyesBlue, false);
            eyesBlue.floatValue = 0f;
            this.pages[0].subObjects.Add(this.eyesBlue);


            //Slugcat Eyes Sprite
            eyes           = new FSprite("FoodCircleB", true);
            eyes.scaleX    = 1f;
            eyes.scaleY    = 1f;
            eyes.color     = new Color(0, 0, 0);
            eyes.x         = 964;
            eyes.y         = manager.rainWorld.screenSize.y - 236;
            eyes.isVisible = true;
            this.pages[0].Container.AddChild(this.eyes);

            //Slugcat Sprite
            slugcat           = new FSprite("slugcatSleeping", true);
            slugcat.scaleX    = 1f;
            slugcat.scaleY    = 1f;
            slugcat.color     = new Color(1f, 1f, 1f);
            slugcat.x         = 970;
            slugcat.y         = manager.rainWorld.screenSize.y - 235;
            slugcat.isVisible = true;
            this.pages[0].Container.AddChild(this.slugcat);

            //Back button
            this.backButton = new SimpleButton(this, this.pages[0], base.Translate("BACK"), "EXIT", new Vector2(100f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.backButton);

            //Back button
            this.backButton = new SimpleButton(this, this.pages[0], base.Translate("BACK"), "EXIT", new Vector2(100f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.backButton);

            //Start Game button
            this.startGameButton = new SimpleButton(this, this.pages[0], "Start Game", "STARTGAME", new Vector2(1060, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.startGameButton);

            //Ready Up button
            this.readyUpButton = new SimpleButton(this, this.pages[0], "Ready UP", "READYUP", new Vector2(940, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.readyUpButton);

            //Multiplayer Chat
            this.gameChat = new MultiplayerChat(this, this.pages[0], new Vector2(320, 125), new Vector2(600, 600));
            this.pages[0].subObjects.Add(this.gameChat);

            //Invite menu
            playerList = new MultiplayerPlayerList(this, this.pages[0], new Vector2(100, 125), new Vector2(200, 600), new Vector2(180, 180));
            this.pages[0].subObjects.Add(this.playerList);

            //Controller Combatability
            this.bodyRed.nextSelectable[1]         = this.readyUpButton;
            this.bodyRed.nextSelectable[3]         = this.bodyGreen;
            this.bodyGreen.nextSelectable[1]       = this.bodyRed;
            this.bodyGreen.nextSelectable[3]       = this.bodyBlue;
            this.bodyBlue.nextSelectable[1]        = this.bodyGreen;
            this.bodyBlue.nextSelectable[3]        = this.eyesRed;
            this.eyesRed.nextSelectable[1]         = this.bodyBlue;
            this.eyesRed.nextSelectable[3]         = this.eyesGreen;
            this.eyesGreen.nextSelectable[1]       = this.eyesRed;
            this.eyesGreen.nextSelectable[3]       = this.eyesBlue;
            this.eyesBlue.nextSelectable[1]        = this.eyesGreen;
            this.eyesBlue.nextSelectable[3]        = this.readyUpButton;
            this.readyUpButton.nextSelectable[0]   = this.backButton;
            this.readyUpButton.nextSelectable[1]   = this.eyesBlue;
            this.readyUpButton.nextSelectable[2]   = this.startGameButton;
            this.readyUpButton.nextSelectable[3]   = this.bodyRed;
            this.startGameButton.nextSelectable[0] = this.readyUpButton;
            this.startGameButton.nextSelectable[1] = this.eyesBlue;
            this.startGameButton.nextSelectable[2] = this.backButton;
            this.startGameButton.nextSelectable[3] = this.bodyRed;
            this.backButton.nextSelectable[0]      = this.startGameButton;
            this.backButton.nextSelectable[2]      = this.readyUpButton;
            this.backButton.nextSelectable[1]      = this.bodyRed;
            this.backButton.nextSelectable[3]      = this.eyesBlue;

            //Some Nice Music :)
            if (manager.musicPlayer != null)
            {
                manager.musicPlayer.MenuRequestsSong("NA_05 - Sparkles", 1.2f, 10f);
            }
        }
Пример #38
0
        public override void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor)
        {
            RoundedRect rect = new RoundedRect(left, bottom, right, top, 0);

            Render(rect, fillColor.GetAsRGBA_Bytes());
        }
Пример #39
0
        public static void Rectangle(this Graphics2D gx, double left, double bottom, double right, double top, ColorRGBA color, double strokeWidth = 1)
        {
            RoundedRect rect = new RoundedRect(left + .5, bottom + .5, right - .5, top - .5, 0);

            gx.Render(new Stroke(strokeWidth).MakeVxs(rect.MakeVxs()), color);
        }