Inheritance: IModelUI
Exemple #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;
        }