コード例 #1
0
        public frmReincarnationMaterialEditor(MaterialItem mi, Material M)
        {
            InitializeComponent();

            cboBaseMaterial.SelectedIndex = 15;

            parent = mi;
            material = (M.SupportingDocuments["Source"] as MT2);

            setMaterial(material);
            pbPreview.Image = M.Texture.GetThumbnail(256);
        }
コード例 #2
0
ファイル: crMT2.cs プロジェクト: DevilboxGames/ToxicRagers
        public static MT2 Load(string path)
        {
            Logger.LogToFile(Logger.LogLevel.Info, path);
            MT2 mt2 = new MT2(XElement.Load(path));

            if (mt2.xml.Descendants("BasedOffOf").Count() > 0)
            {
                string basedOffOf = mt2.xml.Descendants("BasedOffOf").Attributes("Name").First().Value;

                mt2 = (MT2)Activator.CreateInstance(Type.GetType("ToxicRagers.CarmageddonReincarnation.Formats.Materials." + basedOffOf, true, true), mt2.xml);
                mt2.basedOffOf = basedOffOf;
            }

            mt2.name = Path.GetFileNameWithoutExtension(path);

            return mt2;
        }
コード例 #3
0
        private void setUIFromObject(MT2 m)
        {
            foreach (var property in m.GetType().GetProperties())
            {
                if (property.CanRead)
                {
                    object[] attributes = property.GetCustomAttributes(true);
                    bool bRequired = attributes.Any(a => a.GetType() == typeof(Required));

                    switch (property.PropertyType.ToString().Split('.').Last())
                    {
                        case "Vector3":
                            break;

                        case "Single":
                            NumericUpDown nud = (this.Controls.Find("nud" + property.Name, true).FirstOrDefault() as NumericUpDown);
                            if (nud == null) { nud = (NumericUpDown)controlWithTag(property.Name, this).First(); }
                            nud.Value = (Decimal)(Single)property.GetValue(m, null);
                            break;

                        case "Troolean":
                            {
                                CheckBox chk = (this.Controls.Find("chk" + property.Name, true).FirstOrDefault() as CheckBox);
                                if (chk == null) { chk = chkNoSortAlpha; }
                                Troolean value = (Troolean)property.GetValue(m, null);
                                if (value != Troolean.Unset) { chk.Checked = (value == Troolean.True); }
                            }
                            break;

                        case "String":
                            {
                                TextBox txt = (this.Controls.Find("txt" + property.Name, true).FirstOrDefault() as TextBox);
                                if (txt == null) { txt = (TextBox)controlWithTag(property.Name, this).FirstOrDefault(); }
                                if (txt == null)
                                {
                                    Console.WriteLine("Couldn't find txt{0}", property.Name);
                                    continue;
                                }

                                txt.Text = (string)property.GetValue(m, null);
                                setTextBoxState(txt);
                            }
                            break;

                        default:
                            Console.WriteLine("[{2}] {0} = {1}", property.Name, property.GetValue(m, null), property.PropertyType.ToString());
                            break;
                    }

                }
            }
        }
コード例 #4
0
        private void setMaterial(MT2 m)
        {
            lstSamplersAndTexCoordSources.Items.Clear();

            txtMaterialName.Text = m.Name;
            cboBaseMaterial.Text = m.BasedOffOf;

            setUIFromObject(m.Defaults);
            setUIFromObject(m);

            foreach (Sampler sampler in m.Defaults.Samplers)
            {
            }
        }