Esempio n. 1
0
        void Build()
        {
            Color sideColor = new SFML.Graphics.Color(
                DEFAULT_CENTER_COLOR.R,
                DEFAULT_CENTER_COLOR.G,
                DEFAULT_CENTER_COLOR.B,
                DEFAULT_CENTER_COLOR.A);

            Color centerColor = new SFML.Graphics.Color(
                DEFAULT_CENTER_COLOR.R,
                DEFAULT_CENTER_COLOR.G,
                DEFAULT_CENTER_COLOR.B,
                DEFAULT_CENTER_ALPHA);

            SideSquare.AddPoint(new Vector2f(0F, 0F), sideColor, sideColor);
            SideSquare.AddPoint(new Vector2f(Size, 0F), sideColor, sideColor);
            SideSquare.AddPoint(new Vector2f(Size, Size), sideColor, sideColor);
            SideSquare.AddPoint(new Vector2f(0F, Size), sideColor, sideColor);

            float centerOffset = Size * (float)((100D - CENTERSQUARE_SCALE_FACTOR) / 100D / 2D);

            CenterSquare.AddPoint(new Vector2f(centerOffset, centerOffset), centerColor, sideColor);
            CenterSquare.AddPoint(new Vector2f(Size - centerOffset, centerOffset), centerColor, sideColor);
            CenterSquare.AddPoint(new Vector2f(Size - centerOffset, Size - centerOffset), centerColor, sideColor);
            CenterSquare.AddPoint(new Vector2f(centerOffset, Size - centerOffset), centerColor, sideColor);
        }
Esempio n. 2
0
        public AABB(SFML.Window.Vector2f position, float width, float height, SFML.Graphics.Color color)
        {
            Position = position;
            Extents = new SFML.Window.Vector2f(width, height);
            this.color = color;

            Configure();
        }
Esempio n. 3
0
        public AABB(SFML.Window.Vector2f position, Vector2f extents)
        {
            Position = position;
            Extents = extents;

            this.color = Color.White;

            Configure();
        }
Esempio n. 4
0
        public AABB(SFML.Window.Vector2f position, float width, float height)
        {
            Position = position;
            Extents = new SFML.Window.Vector2f(width, height);

            this.color = Color.White;

            Configure();
        }
Esempio n. 5
0
        public AABB(SFML.Window.Vector2f position, Vector2f extents, Color color)
        {
            Position = position;
            Extents = extents;

            this.color = color;

            Configure();
        }
Esempio n. 6
0
        public AABBProjection(AABB start, SFML.Window.Vector2f movement, SFML.Graphics.Color color)
        {
            Start = start;
            End = new AABB(new SFML.Window.Vector2f(start.Position.X + movement.X, start.Position.Y + movement.Y), start.Extents.X, start.Extents.Y, Start.Color);

            this.color = color;

            InitializeSegments();
        }
Esempio n. 7
0
 private void backgroundColourToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorDialog cd = new ColorDialog();
     cd.AnyColor = true;
     cd.FullOpen = true;
     if (cd.ShowDialog() == DialogResult.OK)
     {
         SFML.Graphics.Color colour = new SFML.Graphics.Color();
         colour.R = cd.Color.R;
         colour.G = cd.Color.G;
         colour.B = cd.Color.B;
         m_sfmlControl.BackgroundColour = colour;
     }
 }
Esempio n. 8
0
        public MainViewer()
        {
            InitializeComponent();

            // Initializing variables
            _data = new DataPipeline();
            smiteMap = new SmiteMap();
            teamTemp = new List<int>();

            // Create the smite map. We couldn't do it via the Toolbox because VS2012 couldn't detect
            // SFML library even though it was referenced, so we gotta do it the hard way
            smiteMap.Size = new System.Drawing.Size(963, 891);
            smiteMap.Location = new Point(7, 22);
            grpMap.Controls.Add(smiteMap);

            // By default we would have 0 notification
            notification = 0;

            // By default current map isn't set so
            CurrentMap = -1;

            // Repointing to itself, make this a singleton class
            _instance = this;

            // Setting up both default value for client and server
            _client = new Client(txtHostIP.Text, int.Parse(txtClientPort.Text));
            _server = new Server(int.Parse(txtServerPort.Text), txtServerPass.Text, txtAdminName.Text);

            // Defining 4 initial value for colors - all 4 are blacks
            PickedColor = new SFML.Graphics.Color[4];
            for (int i = 0; i < PickedColor.Length; i++)
                PickedColor[i] = new SFML.Graphics.Color(SFML.Graphics.Color.Black);

            // By default the instance is not a server
            IsServer = false;

            // For drawings
            CurrentSelectedColor = 0;
            PencilSize = 5;
            CurrentTool = (int)ToolType.Pencil;

            // Initialize the team
            BoardTeam1 = new List<GodInstance>();
            BoardTeam2 = new List<GodInstance>();
        }
Esempio n. 9
0
File: Map.cs Progetto: Kukks/CryBits
    private static void Map_Tiles(byte c)
    {
        // Previne erros
        if (Lists.Map.Name == null)
        {
            return;
        }

        // Dados
        System.Drawing.Color TempColor = System.Drawing.Color.FromArgb(Lists.Map.Color);
        SFML.Graphics.Color  Color     = CColor(TempColor.R, TempColor.G, TempColor.B);

        // Desenha todas as camadas dos azulejos
        for (short x = (short)Game.Tile_Sight.X; x <= Game.Tile_Sight.Width; x++)
        {
            for (short y = (short)Game.Tile_Sight.Y; y <= Game.Tile_Sight.Height; y++)
            {
                if (!Map.OutOfLimit(x, y))
                {
                    for (byte q = 0; q <= Lists.Map.Tile[x, y].Data.GetUpperBound(1); q++)
                    {
                        if (Lists.Map.Tile[x, y].Data[c, q].Tile > 0)
                        {
                            int x2 = Lists.Map.Tile[x, y].Data[c, q].X * Game.Grid;
                            int y2 = Lists.Map.Tile[x, y].Data[c, q].Y * Game.Grid;

                            // Desenha o azulejo
                            if (!Lists.Map.Tile[x, y].Data[c, q].Automatic)
                            {
                                Render(Tex_Tile[Lists.Map.Tile[x, y].Data[c, q].Tile], Game.ConvertX(x * Game.Grid), Game.ConvertY(y * Game.Grid), x2, y2, Game.Grid, Game.Grid, Color);
                            }
                            else
                            {
                                Map_Autotile(new Point(Game.ConvertX(x * Game.Grid), Game.ConvertY(y * Game.Grid)), Lists.Map.Tile[x, y].Data[c, q], Color);
                            }
                        }
                    }
                }
            }
        }
    }
Esempio n. 10
0
    public static void Map_Tiles(byte c)
    {
        // Previni erros
        if (Lists.Map.Name == null)
        {
            return;
        }

        // Data
        System.Drawing.Color TempCor = System.Drawing.Color.FromArgb(Lists.Map.Coloração);
        SFML.Graphics.Color  Cor     = CCor(TempCor.R, TempCor.G, TempCor.B);

        // Desenha todas as Layers dos Tiles
        for (short x = (short)Jogo.Tiles_View.X; x <= Jogo.Tiles_View.Width; x++)
        {
            for (short y = (short)Jogo.Tiles_View.Y; y <= Jogo.Tiles_View.Height; y++)
            {
                if (!Map.ForaDoLimite(x, y))
                {
                    for (byte q = 0; q <= Lists.Map.Tile[x, y].Data.GetUpperBound(1); q++)
                    {
                        if (Lists.Map.Tile[x, y].Data[c, q].Tile > 0)
                        {
                            int x2 = Lists.Map.Tile[x, y].Data[c, q].x * Jogo.Grade;
                            int y2 = Lists.Map.Tile[x, y].Data[c, q].y * Jogo.Grade;

                            // Desenha o Tile
                            if (!Lists.Map.Tile[x, y].Data[c, q].Automático)
                            {
                                Desenhar(Tex_Tile[Lists.Map.Tile[x, y].Data[c, q].Tile], Jogo.ConvertX(x * Jogo.Grade), Jogo.ConvertY(y * Jogo.Grade), x2, y2, Jogo.Grade, Jogo.Grade, Cor);
                            }
                            else
                            {
                                Maps_AutoCriação(new Point(Jogo.ConvertX(x * Jogo.Grade), Jogo.ConvertY(y * Jogo.Grade)), Lists.Map.Tile[x, y].Data[c, q], Cor);
                            }
                        }
                    }
                }
            }
        }
    }
        public MainViewer()
        {
            InitializeComponent();
            smiteMap = new SmiteMap();
            smiteMap.Size = new System.Drawing.Size(723, 723);
            smiteMap.Location = new Point(6, 19);
            grpMap.Controls.Add(smiteMap);
            notification = 0;

            _instance = this;
            _client = new Client(txtHostIP.Text, int.Parse(txtClientPort.Text));
            _server = new Server(int.Parse(txtServerPort.Text), txtServerPass.Text, txtAdminName.Text);
            PickedColor = new SFML.Graphics.Color[4];
            for (int i = 0; i < PickedColor.Length; i++)
                PickedColor[i] = new SFML.Graphics.Color();

            IsServer = false;
            CurrentSelectedColor = 0;
            PencilSize = 5;
            CurrentTool = (int)ToolType.Pencil;
        }
Esempio n. 12
0
    public static void AddLine(string Message, SFML.Graphics.Color Cor)
    {
        Chat.Add(new Chat_Structure());
        int i = Chat.Count - 1;

        // Adiciona a Message em uma Line vazia
        Chat[i].Text = Message;
        Chat[i].Cor  = Cor;

        // Remove uma Line se necessário
        if (Chat.Count > Max_Lines)
        {
            Chat.Remove(Chat[0]);
        }
        if (i + Line > Lines_Visíveis + Line)
        {
            Line = (byte)(i - Lines_Visíveis);
        }

        // Torna as Lines visíveis
        Lines_Visible = true;
    }
Esempio n. 13
0
    public static void Add(string Message, SFML.Graphics.Color Cor)
    {
        int    Message_Width, Caixa_Width = Graphics.MySize(Graphics.Tex_Panel[Panels.Locate("Chat").Texture]).Width - 16;
        string Temp_Message; int Separação;

        // Remove os espaços
        Message       = Message.Trim();
        Message_Width = MeasureText_Width(Message);

        // Caso couber, adiciona a Message normalmente
        if (Message_Width < Caixa_Width)
        {
            AddLine(Message, Cor);
        }
        else
        {
            for (int i = 0; i <= Message.Length; i++)
            {
                // Verifica se o Next caráctere é um separável
                switch (Message[i])
                {
                case '-':
                case '_':
                case ' ': Separação = i; break;
                }

                Temp_Message = Message.Substring(0, i);

                // Adiciona o Text à caixa
                if (MeasureText_Width(Temp_Message) > Caixa_Width)
                {
                    AddLine(Temp_Message, Cor);
                    Add(Message.Substring(Temp_Message.Length), Cor);
                    return;
                }
            }
        }
    }
Esempio n. 14
0
    private static void Character(short Texture_Num, Point Position, Game.Directions Direction, byte Column, bool Hurt = false)
    {
        Rectangle Rec_Source = new Rectangle(), Rec_Destiny;
        Size      Size = TSize(Tex_Character[Texture_Num]);

        SFML.Graphics.Color Color = new SFML.Graphics.Color(255, 255, 255);
        byte Line = 0;

        // Direção
        switch (Direction)
        {
        case Game.Directions.Up: Line = Game.Movement_Up; break;

        case Game.Directions.Down: Line = Game.Movement_Down; break;

        case Game.Directions.Left: Line = Game.Movement_Left; break;

        case Game.Directions.Right: Line = Game.Movement_Right; break;
        }

        // Define as propriedades dos retângulos
        Rec_Source.X      = Column * Size.Width / Game.Animation_Amount;
        Rec_Source.Y      = Line * Size.Height / Game.Animation_Amount;
        Rec_Source.Width  = Size.Width / Game.Animation_Amount;
        Rec_Source.Height = Size.Height / Game.Animation_Amount;
        Rec_Destiny       = new Rectangle(Position, Rec_Source.Size);

        // Demonstra que o personagem está sofrendo dano
        if (Hurt)
        {
            Color = new SFML.Graphics.Color(205, 125, 125);
        }

        // Desenha o personagem e sua sombra
        Render(Tex_Shadow, Rec_Destiny.Location.X, Rec_Destiny.Location.Y + Size.Height / Game.Animation_Amount - TSize(Tex_Shadow).Height + 5, 0, 0, Size.Width / Game.Animation_Amount, TSize(Tex_Shadow).Height);
        Render(Tex_Character[Texture_Num], Rec_Source, Rec_Destiny, Color);
    }
Esempio n. 15
0
        /*
         * Saves the selected palette to a .pal file at the directory selected by the user.
         */
        private void savePalButton_Click(object sender, EventArgs e)
        {
            int paletteNumber = palettesListBox.SelectedIndex;

            if (paletteNumber != -1)
            {
                using (SaveFileDialog saveDialogue = new SaveFileDialog())
                {
                    saveDialogue.Filter = "Palette files (*.pal)|*.pal|All files (*.*)|*.*";

                    if (saveDialogue.ShowDialog() == DialogResult.OK)
                    {
                        byte[] paletteData = new byte[64 * 3];

                        for (int i = 0; i < 64; i++)
                        {
                            SFML.Graphics.Color color = palettes[paletteNumber][i];
                            paletteData[(i * 3)]     = color.R;
                            paletteData[(i * 3) + 1] = color.G;
                            paletteData[(i * 3) + 2] = color.B;
                        }

                        System.IO.File.WriteAllBytes(saveDialogue.FileName, paletteData);

                        MessageBox.Show("Successfully Saved.");
                    }
                    else
                    {
                        MessageBox.Show("Failed to save to selected path.");
                    }
                }
            }
            else
            {
                MessageBox.Show("No palette selected.");
            }
        }
        public unsafe void Draw(Texture texture, FloatRect rec, IntRect src, Color color)
        {
            var index = Create(texture);

            fixed(Vertex *fptr = vertices)
            {
                var ptr = fptr + index;

                ptr->Position.X  = rec.Left;
                ptr->Position.Y  = rec.Top;
                ptr->TexCoords.X = src.Left;
                ptr->TexCoords.Y = src.Top;
                ptr->Color       = color;
                ptr++;

                ptr->Position.X  = rec.Left + rec.Width;
                ptr->Position.Y  = rec.Top;
                ptr->TexCoords.X = src.Left + src.Width;
                ptr->TexCoords.Y = src.Top;
                ptr->Color       = color;
                ptr++;

                ptr->Position.X  = rec.Left + rec.Width;
                ptr->Position.Y  = rec.Top + rec.Height;
                ptr->TexCoords.X = src.Left + src.Width;
                ptr->TexCoords.Y = src.Top + src.Height;
                ptr->Color       = color;
                ptr++;

                ptr->Position.X  = rec.Left;
                ptr->Position.Y  = rec.Top + rec.Height;
                ptr->TexCoords.X = src.Left;
                ptr->TexCoords.Y = src.Top + src.Height;
                ptr->Color       = color;
            }
        }
Esempio n. 17
0
        internal static void DrawText(int X, int y, string text, SFML.Graphics.Color color, SFML.Graphics.Color BackColor, RenderWindow target, byte TextSize = 13)
        {
            Text mystring = new Text(text, E_Graphics.SFMLGameFont)
            {
                CharacterSize = TextSize,
                Color         = BackColor,
                Position      = new Vector2f(X - 1, y - 1)
            };

            target.Draw(mystring);

            mystring.Position = new Vector2f(X - 1, y + 1);
            target.Draw(mystring);

            mystring.Position = new Vector2f(X + 1, y + 1);
            target.Draw(mystring);

            mystring.Position = new Vector2f(X + 1, y + -1);
            target.Draw(mystring);

            mystring.Color    = color;
            mystring.Position = new Vector2f(X, y);
            target.Draw(mystring);
        }
Esempio n. 18
0
        /*
         * Loads a palette from a user selected .pal file to be used in the Palette Viewer.
         */
        private void loadPalButton_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openDialogue = new OpenFileDialog())
            {
                openDialogue.Filter = "Palette files (*.pal)|*.pal|All files (*.*)|*.*";

                if (openDialogue.ShowDialog() == DialogResult.OK)
                {
                    byte[] paletteData = System.IO.File.ReadAllBytes(openDialogue.FileName);

                    if (paletteData.Length >= (64 * 3))
                    {
                        SFML.Graphics.Color[] palette = new Color[64];

                        for (int i = 0; i < 64; i++)
                        {
                            SFML.Graphics.Color newColor = new SFML.Graphics.Color(paletteData[(i * 3)], paletteData[(i * 3) + 1], paletteData[(i * 3) + 2]);
                            palette[i] = newColor;
                        }

                        //Accept input for palette name
                        InputBox nameBox = new InputBox();
                        nameBox.Text = "Enter Palette Name:";

                        string paletteName = "New Palette";

                        if (nameBox.ShowDialog() == DialogResult.OK)
                        {
                            paletteName = nameBox.inputTextBox.Text;
                        }

                        addPalette(paletteName, palette);
                    }
                }
            }
        }
Esempio n. 19
0
        public static SystemColor ToSystemColor(this SFMLColor SFMLColor)
        {
            SystemColor temp = SystemColor.FromArgb(SFMLColor.A, SFMLColor.R, SFMLColor.G, SFMLColor.B);

            return(temp);
        }
Esempio n. 20
0
        public void DrawLine(int x, int y, int a, int b, Color color)
        {
            bool localDraw = false;
            if (inDrawingMode == false) {
                BeginDrawing();
                localDraw = true;
            }

            HandleCacheFlushing(CacheMode.Lines, 2, null);

            if (newOrigin != Point.Empty) {
                DrawingSupport.Translate(newOrigin, ref x, ref y);
                DrawingSupport.Translate(newOrigin, ref a, ref b);
            }

            SFML.Graphics.Color sfColor = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);

            m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(x, y), sfColor);
            m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(a, b), sfColor);

            //Vertex[] line = { new Vertex(new Vector2f(x, y), sfColor), new Vertex(new Vector2f(a, b), sfColor) };

            //renderTarget.Draw(line, PrimitiveType.Lines);

            if (localDraw) {
                EndDrawing();
            }
        }
Esempio n. 21
0
        public override void Render()
        {
            if (_items.Count > 0)
            {
                if (Selected < 0 || Selected > _items.Count - 1)
                {
                    Selected = 0;
                }
                else
                {
                    if (_selectionGlow != null)
                    {
                        _selectionGlow.Position =
                            new Vector2i(
                                ClientArea.Left + (int)(ClientArea.Width / 2f - _selectionGlow.ClientArea.Width / 2f),
                                ClientArea.Top + (int)(ClientArea.Height / 2f - _selectionGlow.ClientArea.Height / 2f));
                        _selectionGlow.Render();
                    }

                    KeyValuePair <ImageButton, Object> selected = _items[Selected];
                    selected.Key.Position =
                        new Vector2i(ClientArea.Left + (int)(ClientArea.Width / 2f - selected.Key.ClientArea.Width / 2f),
                                     ClientArea.Top + (int)(ClientArea.Height / 2f - selected.Key.ClientArea.Height / 2f));
                    if (FadeItems)
                    {
                        ctemp = Color.White;
                    }
                    selected.Key.Color = ctemp;
                    selected.Key.Render();

                    int lastPosLeft  = selected.Key.ClientArea.Left - ItemSpacing;
                    int lastPosRight = selected.Key.ClientArea.Right() + ItemSpacing;

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

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

                            if (FadeItems)
                            {
                                ctemp = Color.White.WithAlpha((byte)(baseAlpha / alphaAdj));
                            }
                            selectedLeft.Key.Color = ctemp;

                            selectedLeft.Key.Render();
                        }

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

                            if (FadeItems)
                            {
                                ctemp = Color.White.WithAlpha((byte)(baseAlpha / alphaAdj));
                            }
                            selectedRight.Key.Color = ctemp;
                            selectedRight.Key.Render();
                        }
                    }
                }
            }

            if (ShowArrows)
            {
                _buttonLeft.Render();
                _buttonRight.Render();
            }

            //Gorgon.CurrentRenderTarget.Rectangle(ClientArea.X, ClientArea.Y, ClientArea.Width, ClientArea.Height, System.Drawing.Color.DarkOrange);
        }
Esempio n. 22
0
 public CollisionObject(Vector2f position, Vector2f extents, SFML.Graphics.Color color)
 {
     originalColor = color;
     BoundingBox   = new AABB(position, extents, color);
     Configure();
 }
Esempio n. 23
0
        /// <summary>
        /// Converts a SFML.Graphics.Color to a System.Drawing.Color
        /// </summary>
        /// <param name="color"> SFML.Graphics.Color to convert </param>
        /// <returns></returns>
        public static Color SFMLColorToSystem(SColor color)
        {
            Color temp = Color.FromArgb(color.R, color.G, color.B, color.A);

            return(temp);
        }
Esempio n. 24
0
        private void loadFile()
        {
            Debug.Assert(m_filePath != string.Empty);

            try
            {
                ParticleDefiniton pd;
                JsonSerializer    srlz = new JsonSerializer();
                srlz.NullValueHandling = NullValueHandling.Ignore;

                using (StreamReader sr = new StreamReader(m_filePath))
                    using (JsonReader jr = new JsonTextReader(sr))
                    {
                        pd = srlz.Deserialize <ParticleDefiniton>(jr);
                    }

                m_sfmlControl.BackgroundColour          = intToColour(pd.Editor.BackgroundColour);
                enableMovementToolStripMenuItem.Checked = pd.Editor.EnableMovement;
                m_defaultPos = new Vector2f(pd.Editor.EmitterPosition.X, pd.Editor.EmitterPosition.Y);
                m_particleSystem.position = m_defaultPos;

                switch (pd.BlendMode)
                {
                case "Add":
                    m_particleSystem.blendMode = BlendMode.Add;
                    break;

                case "Alpha":
                    m_particleSystem.blendMode = BlendMode.Alpha;
                    break;

                case "Multiply":
                    m_particleSystem.blendMode = BlendMode.Multiply;
                    break;

                case "None":
                    m_particleSystem.blendMode = BlendMode.None;
                    break;
                }
                comboBoxBlendMode.SelectedItem = m_particleSystem.blendMode;

                m_particleSystem.colour = intToColour(pd.Colour);
                panelColour.BackColor   = System.Drawing.Color.FromArgb(m_particleSystem.colour.A, m_particleSystem.colour.R, m_particleSystem.colour.G, m_particleSystem.colour.B);

                numericUpDownStartDelay.Value = (decimal)pd.Delay;
                numericUpDownDuration.Value   = (decimal)pd.Duration;
                numericUpDownEmitRate.Value   = (decimal)pd.EmitRate;
                numericUpDownInitVelX.Value   = pd.InitialVelocity.X;
                numericUpDownInitVelY.Value   = pd.InitialVelocity.Y;
                numericUpDownLifetime.Value   = (decimal)pd.Lifetime;
                numericUpDownSizeX.Value      = pd.ParticleSize.Width;
                numericUpDownSizeY.Value      = pd.ParticleSize.Height;

                m_particleSystem.randomInitialPositions = null;
                listBoxSpawnPoints.Items.Clear();
                if (pd.RandomInitialPositions.Count > 0)
                {
                    List <Vector2f> randPositions = new List <Vector2f>();
                    foreach (var p in pd.RandomInitialPositions)
                    {
                        randPositions.Add(new Vector2f(p.X, p.Y));
                    }
                    m_particleSystem.randomInitialPositions = randPositions;
                    updateListbox(listBoxSpawnPoints.Items, randPositions);
                }

                m_particleSystem.randomInitialVelocities = null;
                listBoxSpawnVelocities.Items.Clear();
                if (pd.RandomInitialVelocities.Count > 0)
                {
                    List <Vector2f> randVelocities = new List <Vector2f>();
                    foreach (var v in pd.RandomInitialVelocities)
                    {
                        randVelocities.Add(new Vector2f(v.X, v.Y));
                    }
                    m_particleSystem.randomInitialVelocities = randVelocities;
                    updateListbox(listBoxSpawnVelocities.Items, randVelocities);
                }

                listBoxAffectors.Items.Clear();
                m_particleSystem.Affectors.Clear();
                if (pd.Affectors.Count > 0)
                {
                    foreach (var ad in pd.Affectors)
                    {
                        if (ad.Type == AffectorType.Colour.ToString())
                        {
                            SFML.Graphics.Color start = intToColour((int)ad.Data[0]);
                            SFML.Graphics.Color end   = intToColour((int)ad.Data[1]);
                            ColourAffector      ca    = new ColourAffector(start, end, ad.Data[2]);
                            m_particleSystem.Affectors.Add(ca);
                            m_particleSystem.colour = start;
                        }
                        else if (ad.Type == AffectorType.Force.ToString())
                        {
                            ForceAffector fa = new ForceAffector(new Vector2f(ad.Data[0], ad.Data[1]));
                            m_particleSystem.Affectors.Add(fa);
                        }
                        else if (ad.Type == AffectorType.Rotation.ToString())
                        {
                            RotationAffector ra = new RotationAffector(ad.Data[0]);
                            m_particleSystem.Affectors.Add(ra);
                        }
                        else if (ad.Type == AffectorType.Scale.ToString())
                        {
                            ScaleAffector sa = new ScaleAffector(new Vector2f(ad.Data[0], ad.Data[1]));
                            m_particleSystem.Affectors.Add(sa);
                        }
                        else if (ad.Type == AffectorType.Velocity.ToString())
                        {
                            VelocityAffector va = new VelocityAffector(new Vector2f(ad.Data[0], ad.Data[1]));
                            m_particleSystem.addAffector(va);
                        }
                        listBoxAffectors.Items.Add(ad.Type);
                    }
                }

                numericUpDownReleaseCount.Value = pd.ReleaseCount;
                if (!string.IsNullOrEmpty(pd.Texture))
                {
                    string path = pd.Texture;
                    if (!File.Exists(path))
                    {
                        //try reconstructing from known asset paths
                        path = path.Replace('/', '\\');
                        bool loaded = false;
                        foreach (string str in m_AssetPaths)
                        {
                            string temp = str + "\\" + path;
                            if (File.Exists(temp))
                            {
                                m_texture = new Texture(temp);
                                m_particleSystem.texture        = m_texture;
                                textBoxTexturePath.Text         = pd.Texture;
                                panelTexPreview.BackgroundImage = new Bitmap(temp);
                                loaded = true;
                                break;
                            }
                        }
                        if (!loaded)
                        {
                            //last ditch, try working dir
                            string temp = Path.GetFileName(pd.Texture);
                            if (File.Exists(temp))
                            {
                                m_texture = new Texture(temp);
                                m_particleSystem.texture        = m_texture;
                                textBoxTexturePath.Text         = pd.Texture;
                                panelTexPreview.BackgroundImage = new Bitmap(temp);
                            }
                        }
                    }
                    else
                    {
                        m_texture = new Texture(pd.Texture);
                        m_particleSystem.texture        = m_texture;
                        textBoxTexturePath.Text         = pd.Texture;
                        panelTexPreview.BackgroundImage = new Bitmap(pd.Texture);
                    }
                    fitPreviewImage();
                }
                else
                {
                    m_texture = null;
                    m_particleSystem.texture        = null;
                    textBoxTexturePath.Text         = string.Empty;
                    panelTexPreview.BackgroundImage = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failed to open particle file");
                MessageBox.Show("make sure asset paths are valid\n(Options->Add Asset Folder)");
            }
        }
Esempio n. 25
0
 public override void MouseMove(MouseMoveEventArgs e)
 {
     _currentColor = ClientArea.Contains(e.X, e.Y)
                         ? new SFML.Graphics.Color(211, 211, 211)
                         : new SFML.Graphics.Color(128, 128, 128);
 }
Esempio n. 26
0
 public void SetAlpha(double alphaPercentage)
 {
     Color = new SFML.Graphics.Color(
         Color.R,
         Color.G,
         Color.B,
         (byte)(255D * (alphaPercentage / 100D)));
 }
Esempio n. 27
0
 public override void MouseMove(MouseMoveEventArgs e)
 {
     _currentColor = ClientArea.Contains(e.X, e.Y)
                         ? new SFML.Graphics.Color(211, 211, 211)
                         : new SFML.Graphics.Color(128, 128, 128);
 }
Esempio n. 28
0
 public void SetTextColor(SFML.Graphics.Color newColor)
 {
     TextColor = newColor;
     TextPropertiesCallback();
 }
Esempio n. 29
0
 public CollisionObject(Vector2f position, Vector2f extents, SFML.Graphics.Color color)
 {
     originalColor = color;
     BoundingBox = new AABB(position, extents, color);
     Configure();
 }
Esempio n. 30
0
 public CollisionObject()
 {
     originalColor = SFML.Graphics.Color.White;
     Configure();
 }
Esempio n. 31
0
        public void Fill(Rectangle bounds, Color color)
        {
            bool localDraw = false;
            if (inDrawingMode == false) {
                BeginDrawing();
                localDraw = true;
            }

            HandleCacheFlushing(CacheMode.Quads, 4, null);

            if (newOrigin != Point.Empty) {
                DrawingSupport.Translate(newOrigin, ref bounds);
            }

            int right = bounds.X + bounds.Width;
            int bottom = bounds.Y + bounds.Height;
            SFML.Graphics.Color sfColor = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);

            m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(bounds.X, bounds.Y), sfColor);
            m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(right, bounds.Y), sfColor);
            m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(right, bottom), sfColor);
            m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(bounds.X, bottom), sfColor);

            if (localDraw) {
                EndDrawing();
            }
        }
Esempio n. 32
0
File: Map.cs Progetto: Kukks/CryBits
    private static void Map_Autotile(Point Position, Lists.Structures.Map_Tile_Data Dados, SFML.Graphics.Color Cor)
    {
        // Desenha os 4 mini azulejos
        for (byte i = 0; i <= 3; i++)
        {
            Point Destiny = Position, Source = Dados.Mini[i];

            // Partes do azulejo
            switch (i)
            {
            case 1: Destiny.X += 16; break;

            case 2: Destiny.Y += 16; break;

            case 3: Destiny.X += 16; Destiny.Y += 16; break;
            }

            // Renderiza o mini azulejo
            Render(Tex_Tile[Dados.Tile], new Rectangle(Source.X, Source.Y, 16, 16), new Rectangle(Destiny, new Size(16, 16)), Cor);
        }
    }
Esempio n. 33
0
 private void PanelColour_BackColorChanged(object sender, EventArgs e)
 {
     SFML.Graphics.Color colour = new SFML.Graphics.Color();
     colour.R = panelColour.BackColor.R;
     colour.G = panelColour.BackColor.G;
     colour.B = panelColour.BackColor.B;
     m_particleSystem.colour = colour;
 }
Esempio n. 34
0
        public override void Render()
        {
            if (_items.Count > 0)
            {
                if (Selected < 0 || Selected > _items.Count - 1)
                    Selected = 0;
                else
                {
                    if (_selectionGlow != null)
                    {
                        _selectionGlow.Position =
                            new Vector2i(
                                ClientArea.Left + (int) (ClientArea.Width/2f - _selectionGlow.ClientArea.Width/2f),
                                ClientArea.Top + (int) (ClientArea.Height/2f - _selectionGlow.ClientArea.Height/2f));
                        _selectionGlow.Render();
                    }

                    KeyValuePair<ImageButton, Object> selected = _items[Selected];
                    selected.Key.Position =
                        new Vector2i(ClientArea.Left + (int) (ClientArea.Width/2f - selected.Key.ClientArea.Width/2f),
                                  ClientArea.Top + (int) (ClientArea.Height/2f - selected.Key.ClientArea.Height/2f));
                    if (FadeItems)
                        ctemp = Color.White;
                    selected.Key.Color = ctemp;
                    selected.Key.Render();

                    int lastPosLeft = selected.Key.ClientArea.Left - ItemSpacing;
                    int lastPosRight = selected.Key.ClientArea.Right() + ItemSpacing;

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

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

                            if (FadeItems)
                                ctemp = Color.White.WithAlpha((byte)(baseAlpha / alphaAdj));
                            selectedLeft.Key.Color = ctemp;

                            selectedLeft.Key.Render();
                        }

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

                            if (FadeItems)
                                ctemp = Color.White.WithAlpha((byte)(baseAlpha / alphaAdj));
                            selectedRight.Key.Color = ctemp;
                            selectedRight.Key.Render();
                        }
                    }
                }
            }

            if (ShowArrows)
            {
                _buttonLeft.Render();
                _buttonRight.Render();
            }

            //Gorgon.CurrentRenderTarget.Rectangle(ClientArea.X, ClientArea.Y, ClientArea.Width, ClientArea.Height, System.Drawing.Color.DarkOrange);
        }
Esempio n. 35
0
 public void SetGridColor(SFML.Graphics.Color color)
 {
     gridColor = color;
     ApplySettingsCallback();
 }
Esempio n. 36
0
 public static SColor ColorFromARGB(byte A, SColor rgb)
 {
     return(new SColor(A, rgb.R, rgb.G, rgb.B));
 }
Esempio n. 37
0
 public override void MouseMove(MouseMoveEventArgs e)
 {
     _bgcol = ClientArea.Contains(e.X, e.Y)
                  ? new SFML.Graphics.Color(70, 130, 180)
                  : Color.Transparent;
 }
Esempio n. 38
0
        /// <summary>
        /// Converts a System.Drawing.Color to a SFML.Graphics.Color
        /// </summary>
        /// <param name="color"> System.Drawing.Color to convert </param>
        /// <returns></returns>
        public static SColor SystemColorToSFML(Color color)
        {
            SColor temp = new SColor(color.R, color.G, color.B, color.A);

            return(temp);
        }
Esempio n. 39
0
        public void Draw(Texture texture, Vector2f position, IntRect rec, Color color, Vector2f scale,
                                Vector2f origin, float rotation = 0)
        {
            count++;
            Using(texture);
            float sin = 0, cos = 1;
            //FloatMath.SinCos(rotation, out sin, out cos);

            if (true)
            {
                rotation = rotation / 180 * (float)Math.PI;
                sin = (float)Math.Sin(rotation);
                cos = (float)Math.Cos(rotation);
            }

            var pX = -origin.X * scale.X;
            var pY = -origin.Y * scale.Y;
            scale.X *= rec.Width;
            scale.Y *= rec.Height;

            activeTexture.vertices.Append(
                new Vertex(
                    new Vector2f(pX * cos - pY * sin + position.X,
                        pX * sin + pY * cos + position.Y),
                    color,
                    new Vector2f(rec.Left, rec.Top)));


            pX += scale.X;
            activeTexture.vertices.Append(
                new Vertex(
                    new Vector2f(pX * cos - pY * sin + position.X,
                        pX * sin + pY * cos + position.Y),
                    color,
                    new Vector2f(rec.Left + rec.Width, rec.Top)));

            pY += scale.Y;
            activeTexture.vertices.Append(
                new Vertex(
                    new Vector2f(pX * cos - pY * sin + position.X,
                        pX * sin + pY * cos + position.Y),
                    color,
                    new Vector2f(rec.Left+rec.Width, rec.Top+rec.Height)));

            pX -= scale.X;

            activeTexture.vertices.Append(
                new Vertex(
                    new Vector2f(pX * cos - pY * sin + position.X,
                        pX * sin + pY * cos + position.Y),
                    color,
                    new Vector2f(rec.Left, rec.Top+rec.Height)));
        }
Esempio n. 40
0
 private int colourToInt(SFML.Graphics.Color c)
 {
     return((c.R << 24) | (c.G << 16) | (c.B << 8) | 255);
 }
Esempio n. 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapPreviewerBase{T}"/> class.
 /// </summary>
 protected MapPreviewerBase()
 {
     TextureSize     = new Vector2(1024);
     BackgroundColor = new Color(255, 0, 255);
 }
 public CollidableComponent()
 {
     Family     = ComponentFamily.Collidable;
     DebugColor = Color.Red;
     tweakAABB  = new Vector4f(0, 0, 0, 0);
 }
Esempio n. 43
0
 public CollisionObject()
 {
     originalColor = SFML.Graphics.Color.White;
     Configure();
 }
Esempio n. 44
0
    public static void Maps_AutoCriação(Point Position, Lists.Structures.Tile_Data Data, SFML.Graphics.Color Cor)
    {
        // Desenha os 4 mini Tiles
        for (byte i = 0; i <= 3; i++)
        {
            Point Destino = Position, Fonte = Data.Mini[i];

            // Partes do Tile
            switch (i)
            {
            case 1: Destino.X += 16; break;

            case 2: Destino.Y += 16; break;

            case 3: Destino.X += 16; Destino.Y += 16; break;
            }

            // Renderiza o mini Tile
            Desenhar(Tex_Tile[Data.Tile], new Rectangle(Fonte.X, Fonte.Y, 16, 16), new Rectangle(Destino, new Size(16, 16)), Cor);
        }
    }
Esempio n. 45
0
        /// <summary>
        /// erzeugt ein rechteck mit den settings aus den methoden-attributen
        /// </summary>
        /// <param name="window"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="brdrClr"></param>
        /// <param name="fillClr"></param>
        /// <param name="rectName"></param>
        /// <returns></returns>
        protected virtual RectangleShape createRect(RenderWindow window, int x, int y, SFML.Graphics.Color brdrClr, SFML.Graphics.Color fillClr, string rectName = "")
        {
            var recShp = new RectangleShape();

            recShp.Size             = new Vector2f(100, 90);
            recShp.OutlineColor     = brdrClr;
            recShp.FillColor        = fillClr;
            recShp.OutlineThickness = 5;
            recShp.Position         = new Vector2f(x, y);

            window.MouseButtonPressed += (sender, e) =>
            {
                if (recShp.GetGlobalBounds().Contains(e.X, e.Y))
                {
                    rectanglePressed.Invoke($"{ rectName }--:--X-POS {e.X}; Y-POS {e.Y}");
                }
            };
            return(recShp);
        }
Esempio n. 46
0
        public void HighlightCell(Vector2Int cell)
        {
            Color color = new Color(0, 0, 255, 50);

            DrawColorRect(cell, color);
        }
Esempio n. 47
0
        private void btnClrSelect4_Click(object sender, EventArgs e)
        {
            DialogResult result = clrPicker.ShowDialog();
            // See if user pressed ok.
            if (result == DialogResult.OK)
            {
                // Set form background to the selected color.
                PickedColor[3] = new SFML.Graphics.Color(clrPicker.Color.R, clrPicker.Color.G, clrPicker.Color.B, (byte)(trkOpaque.Value * 2.55f));
                btnClrSelect4.BackColor = clrPicker.Color;
            }

            CurrentSelectedColor = 3;
        }
Esempio n. 48
0
        public void DrawColorCell(RenderWindow window, SFML.Graphics.Color fillColor, SFML.Graphics.Color outlineColor, int outlineThickness = 1)
        {
            if (m_PolygonneCell == null)
            {
                ConvexShape polygon = new ConvexShape();
                polygon.SetPointCount(4);
                polygon.SetPoint(0, new Vector2f(this.Points[0].X, this.Points[0].Y));
                polygon.SetPoint(1, new Vector2f(this.Points[1].X, this.Points[1].Y));
                polygon.SetPoint(2, new Vector2f(this.Points[2].X, this.Points[2].Y));
                polygon.SetPoint(3, new Vector2f(this.Points[3].X, this.Points[3].Y));

                polygon.OutlineThickness = outlineThickness;

                m_PolygonneCell = polygon;
            }
            m_PolygonneCell.OutlineColor     = outlineColor;
            m_PolygonneCell.FillColor        = fillColor;
            m_PolygonneCell.OutlineThickness = outlineThickness;
            window.Draw(m_PolygonneCell);
        }
Esempio n. 49
0
        private SFML.Graphics.Color intToColour(int c)
        {
            SFML.Graphics.Color retVal = new SFML.Graphics.Color();
            retVal.R = (byte)((c >> 24) & 0xFF);
            retVal.G = (byte)((c >> 16) & 0xFF);
            retVal.B = (byte)((c >> 8) & 0xFF);
            retVal.A = (byte)(c & 0xFF);

            return retVal;
        }
Esempio n. 50
0
        public ContextMenuButton(ContextMenuEntry entry, Vector2f size, IResourceManager resourceManager)
        {
            _resourceManager = resourceManager;

            UserData = entry.ComponentMessage;
            Size = size;
            _currentColor = new SFML.Graphics.Color(128, 128, 128);
            _iconSprite = _resourceManager.GetSprite(entry.IconName);
            _textLabel = new Label(entry.EntryName, "CALIBRI", _resourceManager);
            _textLabel.Update(0);
        }
 public static Shared.Maths.Color Convert(this SFML.Graphics.Color color)
 {
     return(new Shared.Maths.Color(color.R, color.G, color.B, color.A));
 }
Esempio n. 52
0
 public override void MouseMove(MouseMoveEventArgs e)
 {
     _bgcol = ClientArea.Contains(e.X, e.Y)
                  ? new SFML.Graphics.Color(70, 130, 180)
                  : Color.Transparent;
 }
Esempio n. 53
0
        private void panelAffectorColour_Click(object sender, EventArgs e)
        {
            Panel panel = (Panel)sender;
            var oldColour = panel.BackColor;
            panel.BackColor = getColour();

            if(oldColour != panel.BackColor)
            {
                SFML.Graphics.Color newColour = new SFML.Graphics.Color();
                newColour.R = panel.BackColor.R;
                newColour.G = panel.BackColor.G;
                newColour.B = panel.BackColor.B;

                if(panel == panelEndColour)
                {
                    ((ColourAffector)m_particleSystem.Affectors[listBoxAffectors.SelectedIndex]).EndColour = newColour;
                }
                else
                {
                    ((ColourAffector)m_particleSystem.Affectors[listBoxAffectors.SelectedIndex]).StartColour = newColour;
                    m_particleSystem.colour = newColour;
                }
            }
        }