Exemplo n.º 1
0
        private static SaveableData ToSaveableData(DarkRendererSettings settings, DarkKn5ObjectRenderer renderer)
        {
            var data = SaveHelper <SaveableData> .LoadSerialized(settings.ExportToPresetData());

            if (data == null)
            {
                Logging.Unexpected();
                return(null);
            }

            data.CameraPosition          = Coordinates.Create(renderer.Camera.Position).ToArray();
            data.CameraLookAt            = Coordinates.Create(renderer.CameraOrbit?.Target ?? renderer.Camera.Look).ToArray();
            data.CameraFov               = renderer.Camera.FovY.ToDegrees();
            data.AlignCar                = false;
            data.AlignCameraHorizontally = false;
            data.AlignCameraVertically   = false;

            var car = renderer.CarNode;

            if (car != null)
            {
                data.SteerDeg           = car.SteerDeg;
                data.LeftDoorOpen       = car.LeftDoorOpen;
                data.RightDoorOpen      = car.RightDoorOpen;
                data.HeadlightsEnabled  = car.HeadlightsEnabled;
                data.BrakeLightsEnabled = car.BrakeLightsEnabled;
                data.ShowDriver         = car.IsDriverVisible;
            }

            return(data);
        }
Exemplo n.º 2
0
        public static void Transfer(DarkRendererSettings settings, DarkKn5ObjectRenderer renderer)
        {
            var data = ToSaveableData(settings, renderer);

            var filename = UserPresetsControl.GetCurrentFilename(DarkRendererSettings.DefaultPresetableKeyValue);

            if (filename != null)
            {
                var relative = FileUtils.GetRelativePath(filename, PresetsManager.Instance.Combine(DarkRendererSettings.DefaultPresetableKeyValue));
                filename = relative == filename ? null : Path.Combine(PresetsManager.Instance.Combine(DefaultPresetableKeyValue), relative);
            }

            PresetsManager.Instance.SavePresetUsingDialog(null, DefaultPresetableKeyValue, SaveHelper <SaveableData> .Serialize(data), filename);
        }