AoMModelEditor.GrnUi.LoadUI C# (CSharp) Метод

LoadUI() публичный Метод

public LoadUI ( ) : void
Результат void
        public void LoadUI()
        {
            this.Plugin.Text = MainForm.PluginTitle + " - " + Path.GetFileName(this.FileName);

            this.Plugin.grnObjectsTreeListView.ClearObjects();
            if (this.File.Bones.Count > 0)
            {
                this.Plugin.grnObjectsTreeListView.AddObject(this.File.Bones[0]);
            }
            this.Plugin.grnObjectsTreeListView.AddObjects(this.File.Meshes);
            this.Plugin.grnObjectsTreeListView.AddObjects(this.File.Materials);

            int totalVerts = 0;
            int totalFaces = 0;
            for (int i = 0; i < this.File.Meshes.Count; ++i)
            {
                totalVerts += this.File.Meshes[i].Vertices.Count;
                totalFaces += this.File.Meshes[i].Faces.Count;
            }
            this.Plugin.vertsValueToolStripStatusLabel.Text = totalVerts.ToString();
            this.Plugin.facesValueToolStripStatusLabel.Text = totalFaces.ToString();
            this.Plugin.meshesValueToolStripStatusLabel.Text = this.File.Meshes.Count.ToString();
            this.Plugin.matsValueToolStripStatusLabel.Text = this.File.Materials.Count.ToString();
            this.Plugin.animLengthValueToolStripStatusLabel.Text = this.File.Animation.Duration.ToString();

            this.Plugin.grnExportModelCheckBox.Checked = this.ExportSetting.HasFlag(GrnExportSetting.Model);
            this.Plugin.grnExportAnimCheckBox.Checked = this.ExportSetting.HasFlag(GrnExportSetting.Animation);
        }

Usage Example

Пример #1
0
        public MainForm()
        {
            InitializeComponent();
            this.Icon = Properties.Resources.Cyclops;

            //GrnFile f = new GrnFile();
            //f.Read(File.Open(@"C:\Games\Steam\steamapps\common\Age of Mythology\models\ajax_17youmayfeel.grn", FileMode.Open, FileAccess.Read, FileShare.Read));
            //f.DumpData(File.Open(@"C:\Games\Steam\steamapps\common\Age of Mythology\models\ajax_17youmayfeel.grn", FileMode.Open, FileAccess.Read, FileShare.Read), @"C:\Users\Petar\Desktop\GRN\OUTPUT\OutputAjax_17YouMayFeel6");
            //BrgFile f = new BrgFile(File.Open(@"C:\Games\Steam\steamapps\common\Age of Mythology\models\cavalry g prodromos_attacka.brg", FileMode.Open, FileAccess.Read, FileShare.Read));
            //BrgFile f2 = new BrgFile(File.Open(@"C:\Games\Steam\steamapps\common\Age of Mythology\models\cavalry g prodromos_attacka.brg", FileMode.Open, FileAccess.Read, FileShare.Read));
            //f2.Materials[0].id = 12212;
            //int eq = f.Materials.IndexOf(f2.Materials[0]);

            // Brg Objects Viewer
            this.brgObjectListView.FormatCell         += objectListView1_FormatCell;
            this.brgObjectListView.CellEditStarting   += objectListView1_CellEditStarting;
            this.brgObjectListView.CellEditFinishing  += objectListView1_CellEditFinishing;
            this.brgObjectListView.MouseEnter         += ObjectListView_MouseEnter;
            this.brgObjectListView.CellEditActivation  = ObjectListView.CellEditActivateMode.DoubleClick;
            this.brgObjectListView.ShowGroups          = false;
            this.brgObjectListView.OwnerDraw           = true;
            this.brgObjectListView.UseCellFormatEvents = true;

            // Brg Tree View
            this.brgObjectsTreeListView.MouseEnter += TreeListView_MouseEnter;
            brgObjectsTreeListView.FullRowSelect    = true;
            brgObjectsTreeListView.HideSelection    = false;
            brgObjectsTreeListView.CanExpandGetter  = delegate(object rowObject)
            {
                if (rowObject is BrgMesh)
                {
                    return(((BrgMesh)rowObject).MeshAnimations.Count > 0);
                }

                return(false);
            };
            brgObjectsTreeListView.ChildrenGetter = delegate(object rowObject)
            {
                if (rowObject is BrgMesh)
                {
                    return(((BrgMesh)rowObject).MeshAnimations);
                }

                return(null);
            };
            OLVColumn nameCol = new OLVColumn("Name", "Name");

            nameCol.FillsFreeSpace = true;
            brgObjectsTreeListView.Columns.Add(nameCol);

            // Grn Objects Viewer
            //this.grnObjectListView.FormatCell += objectListView1_FormatCell;
            //this.grnObjectListView.CellEditStarting += objectListView1_CellEditStarting;
            //this.grnObjectListView.CellEditFinishing += objectListView1_CellEditFinishing;
            this.grnObjectListView.MouseEnter        += ObjectListView_MouseEnter;
            this.grnObjectListView.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick;
            this.grnObjectListView.ShowGroups         = false;
            //this.grnObjectListView.OwnerDraw = true;
            //this.grnObjectListView.UseCellFormatEvents = true;

            // Grn Tree View
            this.grnObjectsTreeListView.SelectedIndexChanged += grnObjectsTreeListView_SelectedIndexChanged;
            this.grnObjectsTreeListView.MouseEnter           += TreeListView_MouseEnter;
            grnObjectsTreeListView.FullRowSelect              = true;
            grnObjectsTreeListView.HideSelection              = false;
            grnObjectsTreeListView.CanExpandGetter            = delegate(object rowObject)
            {
                if (rowObject is GrnBone)
                {
                    int rowIndex = grn.File.Bones.IndexOf((GrnBone)rowObject);
                    return(grn.File.Bones.Exists(x => x.ParentIndex == rowIndex));
                }
                else if (rowObject is GrnMaterial)
                {
                    return(((GrnMaterial)rowObject).DiffuseTexture != null);
                }

                return(false);
            };
            grnObjectsTreeListView.ChildrenGetter = delegate(object rowObject)
            {
                if (rowObject is GrnBone)
                {
                    int            rowIndex = grn.File.Bones.IndexOf((GrnBone)rowObject);
                    List <GrnBone> bones    = grn.File.Bones.FindAll(x => x.ParentIndex == rowIndex);
                    bones.Remove((GrnBone)rowObject);
                    return(bones);
                }
                else if (rowObject is GrnMaterial)
                {
                    return(new object[] { ((GrnMaterial)rowObject).DiffuseTexture });
                }

                return(null);
            };
            nameCol       = new OLVColumn("Name", "Name");
            nameCol.Width = 300;
            grnObjectsTreeListView.Columns.Add(nameCol);

            // Model Settings
            Settings.Read();
            brg = new BrgUi(this);
            grn = new GrnUi(this);
            brg.LoadUI();
            grn.LoadUI();
            model = brg;
        }