public BrawlBoxViewerSettings CollectSettings()
        {
            BrawlBoxViewerSettings settings = new BrawlBoxViewerSettings();
            settings._tag = BrawlBoxViewerSettings.Tag;
            settings._version = 4;

            settings.RetrieveCorrAnims = syncAnimationsTogetherToolStripMenuItem.Checked;
            settings.DisplayExternalAnims = chkExternalAnims.Checked;
            settings.DisplayBRRESAnims = chkBRRESAnims.Checked;
            settings.DisplayNonBRRESAnims = chkNonBRRESAnims.Checked;
            settings.SyncTexToObj = syncTexObjToolStripMenuItem.Checked;
            settings.SyncObjToVIS0 = syncObjectsListToVIS0ToolStripMenuItem.Checked;
            settings.DisableBonesOnPlay = disableBonesWhenPlayingToolStripMenuItem.Checked;

            settings._defaultCam = ModelPanel.DefaultTranslate;
            settings._defaultRot = ModelPanel.DefaultRotate;
            settings._amb = ModelPanel.Ambient;
            settings._pos = ModelPanel.LightPosition;
            settings._diff = ModelPanel.Diffuse;
            settings._spec = ModelPanel.Specular;
            settings._yFov = ModelPanel._fovY;
            settings._nearZ = ModelPanel._nearZ;
            settings._farz = ModelPanel._farZ;
            settings._tScale = ModelPanel.TranslationScale;
            settings._rScale = ModelPanel.RotationScale;
            settings._zScale = ModelPanel.ZoomScale;
            settings._orbColor = (ARGBPixel)MDL0BoneNode.DefaultNodeColor;
            settings._lineColor = (ARGBPixel)MDL0BoneNode.DefaultBoneColor;
            settings._floorColor = (ARGBPixel)StaticMainWindow._floorHue;
            settings._undoCount = (uint)_allowedUndos;
            settings._shaderCount = 0;
            settings._matCount = 0;
            settings._emis = ModelPanel.Emission;

            settings.Maximize = chkMaximize.Checked;
            settings.CameraSet = btnSaveCam.Text == "Clear Camera";
            settings.ImageCapFmt = _imgExtIndex;
            settings.Bones = _renderBones;
            settings.Polys = _renderPolygons;
            settings.Wireframe = _renderWireframe;
            settings.Vertices = _renderVertices;
            settings.Normals = _renderNormals;
            settings.HideOffscreen = _dontRenderOffscreen;
            settings.BoundingBox = _renderBox;
            settings.ShowCamCoords = showCameraCoordinatesToolStripMenuItem.Checked;
            settings.Floor = _renderFloor;
            settings.OrthoCam = orthographicToolStripMenuItem.Checked;
            settings.EnableSmoothing = enablePointAndLineSmoothingToolStripMenuItem.Checked;
            settings.EnableText = enableTextOverlaysToolStripMenuItem.Checked;

            settings.LinearCHR = chkLinearCHR.Checked;
            settings.LinearSRT = chkLinearSRT.Checked;
            settings.LinearSHP = chkLinearSHP.Checked;
            settings.LinearLight = chkLinearLight.Checked;
            settings.LinearFog = chkLinearFog.Checked;
            settings.LinearCam = chkLinearCamera.Checked;

            settings.GenTansCHR = chkGenTansCHR.Checked;
            settings.GenTansSRT = chkGenTansSRT.Checked;
            settings.GenTansSHP = chkGenTansSHP.Checked;
            settings.GenTansLight = chkGenTansLight.Checked;
            settings.GenTansFog = chkGenTansFog.Checked;
            settings.GenTansCam = chkGenTansCamera.Checked;

            return settings;
        }
        public unsafe void SaveSettings(bool maximize)
        {
            try
            {
                BrawlBoxViewerSettings settings = new BrawlBoxViewerSettings();
                settings._tag = BrawlBoxViewerSettings.Tag;
                settings._version = 2;
                settings._defaultCam = modelPanel.DefaultTranslate;
                settings._defaultRot = modelPanel.DefaultRotate;
                settings._amb = modelPanel.Ambient;
                settings._pos = modelPanel.LightPosition;
                settings._diff = modelPanel.Diffuse;
                settings._spec = modelPanel.Specular;
                settings._yFov = modelPanel._fovY;
                settings._nearZ = modelPanel._nearZ;
                settings._farz = modelPanel._farZ;
                settings._tScale = modelPanel.TranslationScale;
                settings._rScale = modelPanel.RotationScale;
                settings._zScale = modelPanel.ZoomScale;
                settings._orbColor = (ARGBPixel)MDL0BoneNode.DefaultNodeColor;
                settings._lineColor = (ARGBPixel)MDL0BoneNode.DefaultBoneColor;
                settings._floorColor = (ARGBPixel)StaticMainWindow._floorHue;
                //settings.SetFlags1(
                //    syncAnimationsTogetherToolStripMenuItem.Checked,
                //    true,
                //    syncLoopToAnimationToolStripMenuItem.Checked,
                //    syncTexObjToolStripMenuItem.Checked,
                //    syncObjectsListToVIS0ToolStripMenuItem.Checked,
                //    disableBonesWhenPlayingToolStripMenuItem.Checked,
                //    maximize,
                //    btnSaveCam.Text == "Clear Camera");
                settings._undoCount = (uint)_allowedUndos;
                settings._shaderCount = 0;
                settings._matCount = 0;
                settings._emis = modelPanel.Emission;
                settings.ImageCapFmt = _imgExtIndex;
                settings.Bones = _renderBones;
                settings.Polys = _renderPolygons;
                settings.Wireframe = _renderWireframe;
                settings.Vertices = _renderVertices;
                settings.Normals = _renderNormals;
                settings.HideOffscreen = _dontRenderOffscreen;
                settings.BoundingBox = _renderBox;
                settings.ShowCamCoords = showCameraCoordinatesToolStripMenuItem.Checked;
                settings.Floor = _renderFloor;
                settings.OrthoCam = orthographicToolStripMenuItem.Checked;
                settings.EnableSmoothing = enablePointAndLineSmoothingToolStripMenuItem.Checked;
                settings.EnableText = enableTextOverlaysToolStripMenuItem.Checked;

                //if (BrawlLib.Properties.Settings.Default.External)
                //{
                //    using (FileStream stream = new FileStream(Application.StartupPath + "/brawlbox.settings", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 8, FileOptions.SequentialScan))
                //    {
                //        CompactStringTable s = new CompactStringTable();
                //        s.Add(ScreenCapBgLocText.Text);
                //        stream.SetLength((long)BrawlBoxViewerSettings.Size + s.TotalSize);
                //        using (FileMap map = FileMap.FromStream(stream))
                //        {
                //            *(BrawlBoxViewerSettings*)map.Address = settings;
                //            s.WriteTable(map.Address + BrawlBoxViewerSettings.Size);
                //            ((BrawlBoxViewerSettings*)map.Address)->_screenCapPathOffset = (uint)s[ScreenCapBgLocText.Text] - (uint)map.Address;
                //        }
                //    }
                //}
                //else
                //{
                //    BrawlLib.Properties.Settings.Default.ViewerSettings = settings;
                //    BrawlLib.Properties.Settings.Default.ScreenCapBgLocText = ScreenCapBgLocText.Text;
                //    BrawlLib.Properties.Settings.Default.Save();
                //}

                clearSavedSettingsToolStripMenuItem.Enabled = true;
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        public void DistributeSettings(BrawlBoxViewerSettings settings)
        {
            _updating = true;
            ModelPanel.BeginUpdate();

            syncAnimationsTogetherToolStripMenuItem.Checked = settings.RetrieveCorrAnims;
            syncTexObjToolStripMenuItem.Checked = settings.SyncTexToObj;
            syncObjectsListToVIS0ToolStripMenuItem.Checked = settings.SyncObjToVIS0;
            disableBonesWhenPlayingToolStripMenuItem.Checked = settings.DisableBonesOnPlay;
            chkMaximize.Checked = settings.Maximize;
            chkExternalAnims.Checked = settings.DisplayExternalAnims;
            chkBRRESAnims.Checked = settings.DisplayBRRESAnims;
            chkNonBRRESAnims.Checked = settings.DisplayNonBRRESAnims;

            ModelPanel.Ambient = settings._amb;
            ModelPanel.LightPosition = settings._pos;
            ModelPanel.Diffuse = settings._diff;
            ModelPanel.Specular = settings._spec;
            ModelPanel.Emission = settings._emis;

            ModelPanel._fovY = settings._yFov;
            ModelPanel._nearZ = settings._nearZ;
            ModelPanel._farZ = settings._farz;

            ModelPanel.ZoomScale = settings._zScale;
            ModelPanel.TranslationScale = settings._tScale;
            ModelPanel.RotationScale = settings._rScale;

            MDL0BoneNode.DefaultNodeColor = (Color)settings._orbColor;
            MDL0BoneNode.DefaultBoneColor = (Color)settings._lineColor;
            StaticMainWindow._floorHue = (Color)settings._floorColor;
            if (settings.CameraSet)
            {
                btnSaveCam.Text = "Clear Camera";
                ModelPanel.DefaultTranslate = settings._defaultCam;
                ModelPanel.DefaultRotate = settings._defaultRot;
            }
            else
            {
                btnSaveCam.Text = "Save Camera";
                ModelPanel.DefaultTranslate = new Vector3();
                ModelPanel.DefaultRotate = new Vector2();
            }

            _allowedUndos = settings._undoCount;
            ImgExtIndex = settings.ImageCapFmt;

            RenderBones = settings.Bones;
            RenderWireframe = settings.Wireframe;
            RenderPolygons = settings.Polys;
            RenderVertices = settings.Vertices;
            RenderBox = settings.BoundingBox;
            RenderNormals = settings.Normals;
            DontRenderOffscreen = settings.HideOffscreen;
            showCameraCoordinatesToolStripMenuItem.Checked = settings.ShowCamCoords;
            RenderFloor = settings.Floor;
            enablePointAndLineSmoothingToolStripMenuItem.Checked = settings.EnableSmoothing;
            enableTextOverlaysToolStripMenuItem.Checked = settings.EnableText;

            chkLinearCHR.Checked = settings.LinearCHR;
            chkLinearSRT.Checked = settings.LinearSRT;
            chkLinearSHP.Checked = settings.LinearSHP;
            chkLinearLight.Checked = settings.LinearLight;
            chkLinearFog.Checked = settings.LinearFog;
            chkLinearCamera.Checked = settings.LinearCam;

            chkGenTansCHR.Checked = settings.GenTansCHR;
            chkGenTansSRT.Checked = settings.GenTansSRT;
            chkGenTansSHP.Checked = settings.GenTansSHP;
            chkGenTansLight.Checked = settings.GenTansLight;
            chkGenTansFog.Checked = settings.GenTansFog;
            chkGenTansCamera.Checked = settings.GenTansCam;

            ModelPanel.EndUpdate();
            ModelPanel.Invalidate();
            _updating = false;
        }