示例#1
0
        public override void Render()
        {
            if (drawColor != Color.White)
            {
                _textboxLeft.Color  = CluwneLib.SystemColorToSFML(drawColor);
                _textboxMain.Color  = CluwneLib.SystemColorToSFML(drawColor);
                _textboxRight.Color = CluwneLib.SystemColorToSFML(drawColor);
            }

            _textboxLeft.Draw(_clientAreaLeft);
            _textboxMain.Draw(_clientAreaMain);
            _textboxRight.Draw(_clientAreaRight);

            if (Focus && blinkCount <= 0.25f)
            {
                //Draw Textbox

                // CluwneLib.CurrentRenderTarget.Draw(_caretPos - _caretWidth, Label.Position.Y + (Label.Height/2f) - (_caretHeight/2f),_caretWidth, _caretHeight, new Color(255,255,250));

                if (drawColor != Color.White)
                {
                    _textboxLeft.Color  = CluwneLib.SystemColorToSFML(Color.White);
                    _textboxMain.Color  = CluwneLib.SystemColorToSFML(Color.White);
                    _textboxRight.Color = CluwneLib.SystemColorToSFML(Color.White);
                }
            }

            Label.Color = textColor;
            Label.Text  = _displayText;
            Label.Draw();
        }
        private void ApplyHorizontalReduction(RenderImage source, RenderImage destination)
        {
            int         step = reductionChainCount - 1;
            RenderImage s    = source;
            RenderImage d    = reductionRT[step];

            //  CluwneLib.CurrentShader = reductionEffect.Techniques["HorizontalReduction"];

            while (step >= 0)
            {
                d = reductionRT[step];

                CluwneLib.CurrentRenderTarget = d;
                d.Clear(Color.White);

                //   reductionEffect.Parameters["SourceTexture"].SetValue(s);
                var textureDim = new Vector2(1.0f / s.Width, 1.0f / s.Height);
                //     reductionEffect.Parameters["TextureDimensions"].SetValue(textureDim);
                quadRender.Render(new Vector2(1, 1) * -1, new Vector2(1, 1));
                s = d;
                step--;
            }

            //copy to destination
            CluwneLib.CurrentRenderTarget = destination;
            // CluwneLib.CurrentShader = reductionEffect.Techniques["Copy"];
            //      reductionEffect.Parameters["SourceTexture"].SetValue(d);
            CluwneLib.CurrentRenderTarget.Clear(CluwneLib.SystemColorToSFML(Color.White));
            quadRender.Render(new Vector2(1, 1) * -1, new Vector2(1, 1));

            //     reductionEffect.Parameters["SourceTexture"].SetValue(reductionRT[reductionChainCount - 1]);
            CluwneLib.CurrentRenderTarget = null;
        }
示例#3
0
        /// <summary>
        /// Draws the entire Renderimage to the named position.
        /// </summary>
        public void Blit(Vector2 Position, Color color)
        {
            Display();
            CluwneSprite _blit = new CluwneSprite("_blit" + _key, base.Texture);

            _blit.Position = Position;
            _blit.Color    = CluwneLib.SystemColorToSFML(color);
            _blit.Draw();
        }
示例#4
0
 public override void Render()
 {
     if (disposing || !IsVisible())
     {
         return;
     }
     _eraserButton.Color = _placementManager.Eraser ? CluwneLib.SystemColorToSFML(Color.Tomato) : CluwneLib.SystemColorToSFML(Color.White);
     base.Render();
 }
示例#5
0
        /// <summary>
        /// Draws the RenderImage to a CluwneSprite and then to the current RenderTarget
        /// </summary>
        /// <param name="posX"> Position X of CluwneSprite</param>
        /// <param name="posY"> Position Y of CluwneSprite </param>
        /// <param name="widthX"> Width of CluwneSprite </param>
        /// <param name="heightY"> Height of CluwneSprite </param>
        public void Blit(int posX, int posY, uint widthX, uint heightY)
        {
            this.Display();
            CluwneSprite _blit = new CluwneSprite("_blit" + _key, this);

            _blit.Position = new Vector2(posX, posY);
            _blit.Size     = new Vector2(widthX, heightY);
            _blit.Color    = CluwneLib.SystemColorToSFML(Color.Transparent);
            _blit.Draw();
        }
        public override void Render()
        {
            if (disposing || !IsVisible())
            {
                return;
            }

            clippingRI.Clear(DrawBackground ? CluwneLib.SystemColorToSFML(BackgroundColor) : SFML.Graphics.Color.Transparent);
            clippingRI.BeginDrawing();

            foreach (GuiComponent component in components)
            {
                if (inner_focus != null && component == inner_focus)
                {
                    continue;
                }
                Point oldPos = component.Position;
                component.Position = new Point(component.Position.X - (int)scrollbarH.Value,
                                               component.Position.Y - (int)scrollbarV.Value);
                component.Update(0); //2 Updates per frame D:
                component.Render();
                if (CluwneLib.Debug.RenderingDelay > 0)
                {
                    clippingRI.EndDrawing();
                    clippingRI.Blit(Position, Color.White);
                    clippingRI.BeginDrawing();
                }
                component.Position = oldPos;
                component.Update(0);
            }

            if (inner_focus != null)
            {
                Point oldPos = inner_focus.Position;
                inner_focus.Position = new Point(inner_focus.Position.X - (int)scrollbarH.Value,
                                                 inner_focus.Position.Y - (int)scrollbarV.Value);
                inner_focus.Update(0); //2 Updates per frame D:
                inner_focus.Render();
                inner_focus.Position = oldPos;
                inner_focus.Update(0);
            }

            clippingRI.EndDrawing();
            clippingRI.Blit(Position, Color.White);
            // clippingRI.Blit(Position.X, Position.Y,clippingRI.Height, clippingRI.Width, Color.White, BlitterSizeMode.Crop);

            scrollbarH.Render();
            scrollbarV.Render();

            if (DrawBorder)
            {
                CluwneLib.drawHollowRectangle(ClientArea.X, ClientArea.Y, ClientArea.Width, ClientArea.Height,
                                              BorderSize, Color.Black);
            }
        }
 public override void Render()
 {
     if (spriteToDraw != null)
     {
         spriteToDraw.Color    = pManager.ValidPosition ? CluwneLib.SystemColorToSFML(Color.ForestGreen) : CluwneLib.SystemColorToSFML(Color.IndianRed);
         spriteToDraw.Position = new Vector2(mouseScreen.X - (spriteToDraw.Width / 2f),
                                             mouseScreen.Y - (spriteToDraw.Height / 2f));
         //Centering the sprite on the cursor.
         spriteToDraw.Draw();
         spriteToDraw.Color = CluwneLib.SystemColorToSFML(Color.White);
     }
 }
示例#8
0
        /// <summary>
        /// Creates a TextSprite
        /// </summary>
        /// <param name="Label"> ID of the TextSprite</param>
        /// <param name="x"> position X of TextSprite </param>
        /// <param name="y"> Position Y of TextSprite </param>
        /// <param name="width"> Width of TextSprite </param>
        /// <param name="height"> Height of TextSprite </param>
//        public TextSprite(string Label, int x, int y, int width, int height)
//        {
//            this.Position = new Vector2(x, y);
//        }

        /// <summary>
        /// Draws the TextSprite to the CurrentRenderTarget
        /// </summary>
        ///
        #endregion

        #region Methods
        public void Draw(RenderTarget target)
        {
            if (CluwneLib.Debug.Fontsize > 0)
            {
                _textSprite.CharacterSize = CluwneLib.Debug.Fontsize;
            }
            _textSprite.Position = new Vector2(Position.X, Position.Y); // -(_textSprite.GetLocalBounds().Height/2f));
            _textSprite.Color    = CluwneLib.SystemColorToSFML(Color);
            target.Draw(_textSprite);

            if (CluwneLib.Debug.TextBorders)
            {
                FloatRect fr = _textSprite.GetGlobalBounds();
                CluwneLib.drawHollowRectangle((int)fr.Left, (int)fr.Top, (int)fr.Width, (int)fr.Height, 1.0f, Color.Red);
            }
        }
示例#9
0
        /// <summary>
        /// Scale & optionally crop
        /// </summary>
        /// <param name="destination">The exact rectangle you wish to fill - scales to this size</param>
        /// <param name="optionalcrop">To take a subset of the original texture instead of the whole texture</param>
        /// <param name="color">Color.</param>
        public void Blit(IntRect destination, IntRect optionalcrop, Color color)
        {
            CluwneSprite _blit;

            Display();
            if (optionalcrop == null)
            {
                _blit = new CluwneSprite("_blit" + _key, base.Texture);
            }
            else
            {
                _blit = new CluwneSprite("_blit" + _key, base.Texture, optionalcrop);
            }
            _blit.Color = CluwneLib.SystemColorToSFML(color);
            _blit.Draw(destination);
        }
        private void ExecuteTechnique(Image source, RenderImage destination, string techniqueName, RenderImage shadowMap)
        {
            Vector2 renderTargetSize;

            renderTargetSize = new Vector2(baseSize, baseSize);
            CluwneLib.CurrentRenderTarget = destination;
            CluwneLib.CurrentRenderTarget.Clear(CluwneLib.SystemColorToSFML(Color.White));

            //CluwneLib.CurrentShader = resolveShadowsEffect.Techniques[techniqueName];
            // resolveShadowsEffect.Parameters["renderTargetSize"].SetValue(renderTargetSize);
            // if (source != null)
            //     resolveShadowsEffect.Parameters["InputTexture"].SetValue(source);
            // if (shadowMap != null)
            //     resolveShadowsEffect.Parameters["ShadowMapTexture"].SetValue(shadowMap);

            quadRender.Render(new Vector2(1, 1) * -1, new Vector2(1, 1));

            CluwneLib.CurrentRenderTarget = null;
        }
示例#11
0
        public override void Render()
        {
            if (_items.Count > 0)
            {
                if (ScrollOffset < 0 || ScrollOffset > _items.Count - 1)
                {
                    ScrollOffset = 0;
                }
                else
                {
                    KeyValuePair <ImageButton, Object> middle = _items[ScrollOffset];
                    middle.Key.Position =
                        new Point(ItemOffsets.Width + ClientArea.Left + (int)(ClientArea.Width / 2f - middle.Key.ClientArea.Width / 2f),
                                  ItemOffsets.Height + ClientArea.Top + (int)(ClientArea.Height / 2f - middle.Key.ClientArea.Height / 2f));
                    if (FadeItems)
                    {
                        middle.Key.Color = CluwneLib.SystemColorToSFML(Color.White);
                    }

                    if (_selectionGlow != null && Selected == ScrollOffset)
                    {
                        _selectionGlow.Position = new Point(ItemOffsets.Width + ClientArea.Left + (int)(ClientArea.Width / 2f - _selectionGlow.ClientArea.Width / 2f), middle.Key.ClientArea.Top + (int)(middle.Key.ClientArea.Height / 2f - _selectionGlow.ClientArea.Height / 2f));
                        _selectionGlow.Render();
                    }

                    middle.Key.Render();

                    int lastPosLeft  = middle.Key.ClientArea.Left - ItemSpacing;
                    int lastPosRight = middle.Key.ClientArea.Right + ItemSpacing;

                    for (int i = 1; i <= AdditionalColumns; i++)
                    {
                        float       alphaAdj  = 1 + AdditionalColumns - (AdditionalColumns / (float)i);
                        const float baseAlpha = 200;

                        //Left
                        if ((ScrollOffset - i) >= 0 && (ScrollOffset - i) <= _items.Count - 1)
                        {
                            KeyValuePair <ImageButton, Object> currLeft = _items[(ScrollOffset - i)];
                            currLeft.Key.Position = new Point(lastPosLeft - currLeft.Key.ClientArea.Width, ClientArea.Top + (int)(ClientArea.Height / 2f - currLeft.Key.ClientArea.Height / 2f));
                            lastPosLeft           = currLeft.Key.ClientArea.Left - ItemSpacing;

                            if (_selectionGlow != null && (ScrollOffset - i) == Selected)
                            {
                                _selectionGlow.Position = new Point(currLeft.Key.ClientArea.Left + (int)(currLeft.Key.ClientArea.Width / 2f - _selectionGlow.ClientArea.Width / 2f), currLeft.Key.ClientArea.Top + (int)(currLeft.Key.ClientArea.Height / 2f - _selectionGlow.ClientArea.Height / 2f));
                                _selectionGlow.Render();
                            }

                            if (FadeItems)
                            {
                                currLeft.Key.Color = CluwneLib.ColorFromARGB((byte)(baseAlpha / alphaAdj), Color.White);
                            }

                            currLeft.Key.Render();
                        }

                        //Right
                        if ((ScrollOffset + i) >= 0 && (ScrollOffset + i) <= _items.Count - 1)
                        {
                            KeyValuePair <ImageButton, Object> currRight = _items[(ScrollOffset + i)];
                            currRight.Key.Position = new Point(lastPosRight, ClientArea.Top + (int)(ClientArea.Height / 2f - currRight.Key.ClientArea.Height / 2f));
                            lastPosRight           = currRight.Key.ClientArea.Right + ItemSpacing;

                            if (_selectionGlow != null && (ScrollOffset + i) == Selected)
                            {
                                _selectionGlow.Position = new Point(currRight.Key.ClientArea.Left + (int)(currRight.Key.ClientArea.Width / 2f - _selectionGlow.ClientArea.Width / 2f), currRight.Key.ClientArea.Top + (int)(currRight.Key.ClientArea.Height / 2f - _selectionGlow.ClientArea.Height / 2f));
                                _selectionGlow.Render();
                            }

                            if (FadeItems)
                            {
                                currRight.Key.Color = CluwneLib.ColorFromARGB((byte)(baseAlpha / alphaAdj), Color.White);
                            }

                            currRight.Key.Render();
                        }
                    }
                }
            }

            if (ShowArrows && ScrollingNeeded())
            {
                _buttonLeft.Render();
                _buttonRight.Render();
            }
        }
示例#12
0
 /// <summary>
 /// Clears the RenderImage with the specified color
 /// </summary>
 /// <param name="Color"> Color used to cover everything </param>
 public void Clear(Color Color)
 {
     this.Clear(CluwneLib.SystemColorToSFML(Color));
 }