Ejemplo n.º 1
0
        public void SelectTexture(TextureItem item)
        {
            if (_freeze)
            {
                return;
            }

            if (item == null)
            {
                SelectedTexturesList.SetSelectedTextures(new TextureItem[0]);
                return;
            }

            UpdateRecentTextureList();

            // If the texture is in the list of selected faces, select the texture in that list
            var sl = SelectedTexturesList.GetTextures();

            if (sl.Any(x => String.Equals(x.Name, item.Name, StringComparison.InvariantCultureIgnoreCase)))
            {
                SelectedTexturesList.SetSelectedTextures(new[] { item });
                SelectedTexturesList.ScrollToItem(item);
            }
            else if (RecentTexturesList.GetTextures().Contains(item))
            {
                // Otherwise, select the texture in the recent list
                RecentTexturesList.SetSelectedTextures(new[] { item });
                RecentTexturesList.ScrollToItem(item);
            }
            RecentTexturesList.Refresh();
            SelectedTexturesList.Refresh();
        }
Ejemplo n.º 2
0
 public TextureItem GetFirstSelectedTexture()
 {
     return(RecentTexturesList
            .GetSelectedTextures()
            .Union(SelectedTexturesList.GetSelectedTextures())
            .FirstOrDefault());
 }
Ejemplo n.º 3
0
        public void SelectTexture(TextureItem item)
        {
            if (item == null)
            {
                SelectedTexturesList.SetSelectedTextures(new TextureItem[0]);
                return;
            }

            UpdateRecentTextureList();

            // If the texture is in the list of selected faces, select the texture in that list
            var sl = SelectedTexturesList.GetTextures();

            if (sl.Contains(item))
            {
                SelectedTexturesList.SetSelectedTextures(new[] { item });
                SelectedTexturesList.ScrollToItem(item);
            }
            else if (RecentTexturesList.GetTextures().Contains(item))
            {
                // Otherwise, select the texture in the recent list
                RecentTexturesList.SetSelectedTextures(new[] { item });
                RecentTexturesList.ScrollToItem(item);
            }
            RecentTexturesList.Refresh();
            SelectedTexturesList.Refresh();
        }
Ejemplo n.º 4
0
        private void TextureSelectionChanged(object sender, IEnumerable <TextureItem> selection)
        {
            if (_freeze)
            {
                return;
            }

            _freeze = true;
            var item = selection.FirstOrDefault();

            if (selection.Any())
            {
                if (sender == SelectedTexturesList)
                {
                    RecentTexturesList.SetSelectedTextures(new TextureItem[0]);
                }
                if (sender == RecentTexturesList)
                {
                    SelectedTexturesList.SetSelectedTextures(new TextureItem[0]);
                }
            }
            else
            {
                item = RecentTexturesList
                       .GetSelectedTextures()
                       .Union(SelectedTexturesList.GetSelectedTextures())
                       .FirstOrDefault();
            }
            TextureDetailsLabel.Text = "";
            if (item != null)
            {
                TextureDetailsLabel.Text = string.Format("{0} ({1} x {2})", item.Name, item.Width, item.Height);
            }
            _freeze = false;
        }
Ejemplo n.º 5
0
        public void SelectionChanged()
        {
            _freeze = true;

            var faces = Document.Selection.GetSelectedFaces().ToList();

            _currentTextureProperties.Reset(faces);

            ScaleXValue.Value   = _currentTextureProperties.XScale;
            ScaleYValue.Value   = _currentTextureProperties.YScale;
            ShiftXValue.Value   = _currentTextureProperties.XShift;
            ShiftYValue.Value   = _currentTextureProperties.YShift;
            RotationValue.Value = _currentTextureProperties.Rotation;

            if (_currentTextureProperties.DifferentXScaleValues)
            {
                ScaleXValue.Text = "";
            }
            if (_currentTextureProperties.DifferentYScaleValues)
            {
                ScaleYValue.Text = "";
            }
            if (_currentTextureProperties.DifferentXShiftValues)
            {
                ShiftXValue.Text = "";
            }
            if (_currentTextureProperties.DifferentYShiftValues)
            {
                ShiftYValue.Text = "";
            }
            if (_currentTextureProperties.DifferentRotationValues)
            {
                RotationValue.Text = "";
            }

            if (_currentTextureProperties.AllAlignedToFace)
            {
                AlignToFaceCheckbox.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneAlignedToFace)
            {
                AlignToFaceCheckbox.CheckState = CheckState.Unchecked;
            }
            else
            {
                AlignToFaceCheckbox.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllAlignedToWorld)
            {
                AlignToWorldCheckbox.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneAlignedToWorld)
            {
                AlignToWorldCheckbox.CheckState = CheckState.Unchecked;
            }
            else
            {
                AlignToWorldCheckbox.CheckState = CheckState.Indeterminate;
            }

            TextureDetailsLabel.Text = "";
            var textures = new List <TextureItem>();

            foreach (var face in faces)
            {
                var tex = face.Texture;

                var name = tex.Texture == null ? tex.Name : tex.Texture.Name;
                if (textures.Any(x => String.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase)))
                {
                    continue;
                }

                var item = Document.TextureCollection.GetItem(name) ?? new TextureItem(null, name, TextureFlags.Missing, 64, 64);
                textures.Add(item);
            }

            if (textures.Any())
            {
                var t      = textures[0];
                var format = t.Flags.HasFlag(TextureFlags.Missing) ? "{0}" : "{0} ({1}x{2})";
                TextureDetailsLabel.Text = string.Format(format, t.Name, t.Width, t.Height);
            }

            SelectedTexturesList.SetTextureList(textures);
            SelectedTexturesList.SetSelectedTextures(textures);
            RecentTexturesList.SetSelectedTextures(new TextureItem[0]);
            HideMaskCheckbox.Checked = Document.Map.HideFaceMask;
            if (LeftClickCombo.SelectedIndex < 0)
            {
                LeftClickCombo.SelectedIndex = 0;
            }
            if (RightClickCombo.SelectedIndex < 0)
            {
                RightClickCombo.SelectedIndex = 0;
            }

            _freeze = false;
        }
Ejemplo n.º 6
0
 private void UpdateRecentTextureList()
 {
     RecentTexturesList.SetTextureList(Document.TextureCollection.GetRecentTextures().Where(x => x.Name.ToLower().Contains(RecentFilterTextbox.Text.ToLower())));
 }
Ejemplo n.º 7
0
 public IEnumerable <TextureItem> GetSelectedTextures()
 {
     return(RecentTexturesList
            .GetSelectedTextures()
            .Union(SelectedTexturesList.GetSelectedTextures()));
 }
Ejemplo n.º 8
0
 public void Clear()
 {
     SelectedTexturesList.Clear();
     RecentTexturesList.Clear();
     _currentTextureProperties.Reset();
 }
Ejemplo n.º 9
0
        public void SelectionChanged()
        {
            _freeze = true;

            var faces = Document.Selection.GetSelectedFaces().ToList();

            _currentTextureProperties.Reset(faces);

            ScaleXValue.Value       = _currentTextureProperties.XScale;
            ScaleYValue.Value       = _currentTextureProperties.YScale;
            ShiftXValue.Value       = _currentTextureProperties.XShift;
            ShiftYValue.Value       = _currentTextureProperties.YShift;
            RotationValue.Value     = _currentTextureProperties.Rotation;
            TranslucencyValue.Value = (decimal)_currentTextureProperties.Translucency;

            if (_currentTextureProperties.DifferentXScaleValues)
            {
                ScaleXValue.Text = "";
            }
            if (_currentTextureProperties.DifferentYScaleValues)
            {
                ScaleYValue.Text = "";
            }
            if (_currentTextureProperties.DifferentXShiftValues)
            {
                ShiftXValue.Text = "";
            }
            if (_currentTextureProperties.DifferentYShiftValues)
            {
                ShiftYValue.Text = "";
            }
            if (_currentTextureProperties.DifferentRotationValues)
            {
                RotationValue.Text = "";
            }
            if (_currentTextureProperties.DifferentTranslucencyValues)
            {
                TranslucencyValue.Text = "";
            }

            if (_currentTextureProperties.AllAlignedToFace)
            {
                AlignToFaceCheckbox.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneAlignedToFace)
            {
                AlignToFaceCheckbox.CheckState = CheckState.Unchecked;
            }
            else
            {
                AlignToFaceCheckbox.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllAlignedToWorld)
            {
                AlignToWorldCheckbox.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneAlignedToWorld)
            {
                AlignToWorldCheckbox.CheckState = CheckState.Unchecked;
            }
            else
            {
                AlignToWorldCheckbox.CheckState = CheckState.Indeterminate;
            }

            //GBSP Flags
            if (_currentTextureProperties.AllMirror)
            {
                chkMirror.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneMirror)
            {
                chkMirror.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkMirror.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllFullBright)
            {
                chkFullBright.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneFullBright)
            {
                chkFullBright.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkFullBright.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllSky)
            {
                chkSky.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneSky)
            {
                chkSky.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkSky.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllLight)
            {
                chkLight.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneLight)
            {
                chkLight.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkLight.CheckState = CheckState.Indeterminate;
            }

            //if (_currentTextureProperties.AllSelected) chkSelected.CheckState = CheckState.Checked;
            //else if (_currentTextureProperties.NoneSelected) chkSelected.CheckState = CheckState.Unchecked;
            //else chkSelected.CheckState = CheckState.Indeterminate;

            if (_currentTextureProperties.AllFixedHull)
            {
                chkFixedHull.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneFixedHull)
            {
                chkFixedHull.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkFixedHull.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllGouraud)
            {
                chkGouraud.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneGouraud)
            {
                chkGouraud.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkGouraud.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllFlat)
            {
                chkFlat.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneFlat)
            {
                chkFlat.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkFlat.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllTextureLocked)
            {
                chkTextureLocked.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneTextureLocked)
            {
                chkTextureLocked.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkTextureLocked.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllVisible)
            {
                chkVisible.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneVisible)
            {
                chkVisible.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkVisible.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllSheet)
            {
                chkSheet.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneSheet)
            {
                chkSheet.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkSheet.CheckState = CheckState.Indeterminate;
            }

            if (_currentTextureProperties.AllTransparent)
            {
                chkTransparent.CheckState = CheckState.Checked;
            }
            else if (_currentTextureProperties.NoneTransparent)
            {
                chkTransparent.CheckState = CheckState.Unchecked;
            }
            else
            {
                chkTransparent.CheckState = CheckState.Indeterminate;
            }

            TextureDetailsLabel.Text = "";
            var textures = new List <TextureItem>();

            foreach (var face in faces)
            {
                var tex = face.Texture;

                var name = tex.Texture == null ? tex.Name : tex.Texture.Name;
                if (textures.Any(x => String.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase)))
                {
                    continue;
                }

                var item = Document.TextureCollection.GetItem(name) ?? new TextureItem(null, name, TextureFlags.Missing, 64, 64);
                textures.Add(item);
            }

            chkGBSPAEnableAll.Checked = false;
            btnGBSPAReset.Enabled     = false;
            if (faces.Count() == 1)
            {
                //0-AX  1-AY  2-AZ 3-TX
                //4-BX  5-BY  6-BZ 7-TY
                //8-CX  9-CY 10-CZ 11-TZ
                txtAX.Text = faces[0].Texture.TransformAngleRF[0].ToString();
                txtAY.Text = faces[0].Texture.TransformAngleRF[1].ToString();
                txtAZ.Text = faces[0].Texture.TransformAngleRF[2].ToString();

                txtBX.Text = faces[0].Texture.TransformAngleRF[4].ToString();
                txtBY.Text = faces[0].Texture.TransformAngleRF[5].ToString();
                txtBZ.Text = faces[0].Texture.TransformAngleRF[6].ToString();

                txtCX.Text = faces[0].Texture.TransformAngleRF[8].ToString();
                txtCY.Text = faces[0].Texture.TransformAngleRF[9].ToString();
                txtCZ.Text = faces[0].Texture.TransformAngleRF[10].ToString();

                txtPosX.Text = faces[0].Texture.PositionRF.X.ToString();
                txtPosY.Text = faces[0].Texture.PositionRF.Y.ToString();
                txtPosZ.Text = faces[0].Texture.PositionRF.Z.ToString();

                txtUX.Text = faces[0].Texture.UAxis.X.ToString();
                txtUY.Text = faces[0].Texture.UAxis.Y.ToString();
                txtUZ.Text = faces[0].Texture.UAxis.Z.ToString();

                txtVX.Text = faces[0].Texture.VAxis.X.ToString();
                txtVY.Text = faces[0].Texture.VAxis.Y.ToString();
                txtVZ.Text = faces[0].Texture.VAxis.Z.ToString();
            }
            else
            {
                txtAX.Text = txtBX.Text = txtCX.Text = "";
                txtAY.Text = txtBY.Text = txtCY.Text = "";
                txtAZ.Text = txtBZ.Text = txtCZ.Text = "";
                txtUX.Text = txtUY.Text = txtUZ.Text = "";
                txtVX.Text = txtVY.Text = txtVZ.Text = "";
            }

            if (textures.Any())
            {
                var t      = textures[0];
                var format = t.Flags.HasFlag(TextureFlags.Missing) ? "{0}" : "{0} ({1}x{2})";
                TextureDetailsLabel.Text = string.Format(format, t.Name, t.Width, t.Height);
            }

            SelectedTexturesList.SetTextureList(textures);
            SelectedTexturesList.SetSelectedTextures(textures);
            RecentTexturesList.SetSelectedTextures(new TextureItem[0]);
            HideMaskCheckbox.Checked = Document.Map.HideFaceMask;
            if (LeftClickCombo.SelectedIndex < 0)
            {
                LeftClickCombo.SelectedIndex = 0;
            }
            if (RightClickCombo.SelectedIndex < 0)
            {
                RightClickCombo.SelectedIndex = 0;
            }

            _freeze = false;
        }