Пример #1
0
        protected override void LoadContent()
        {
            _s = new SpriteBatch(GraphicsDevice);

            Global.Game = this;

            Settings settings = Utility.LoadJson <Settings>("Settings.json");

            _graphics.PreferredBackBufferWidth  = settings.Width;
            _graphics.PreferredBackBufferHeight = settings.Height;
            IsFixedTimeStep = settings.IsFixedTimeStep;
            _graphics.SynchronizeWithVerticalRetrace = settings.IsVSync;
            _graphics.ApplyChanges();

            _historyHandler = new HistoryHandler(null);

            _quadtree         = new Quadtree <Entity>();
            _selectedEntities = new Quadtree <Entity>();
            Camera.Setup();
            _selection = new RectEdit();
            _edit      = new RectEdit();

            Assets.LoadFonts(Content, GraphicsDevice);
            Assets.Setup(Content);

            InputHelper.Setup(this);
        }
Пример #2
0
        /**
         * Duplicates the Prepar3D.exe file and renames it to FSX.exe - some add ons are looking for the FSX.exe file inside the main folder.
         */
        public static bool CreateFakeFsxExecutable(string newSimPath)
        {
            if (newSimPath.Equals("") || !SimulatorPathExists(newSimPath))
            {
                return(false);
            }

            try
            {
                if (File.Exists(newSimPath + "\\Prepar3D.exe"))
                {
                    File.Copy(newSimPath + "\\Prepar3D.exe", newSimPath + "\\fsx.exe", true);
                    HistoryHandler.AppendHistory("2," + newSimPath);

                    return(true);
                }

                return(false);
            }
            catch (Exception e)
            {
                ErrorLogger.LogError("Could not create fake fsx file, function createFakeFsxExecutable() - " + e.ToString());
                return(false);
            }
        }
Пример #3
0
        public void TestSerialise()
        {
            var hLoader = new HistoryHandler();

            hLoader.Load();
            hLoader.Save(hLoader.UsersHistory);
        }
Пример #4
0
 public HistoryChartViewModel(Dispatcher dispatcher)
 {
     _dispatcher = dispatcher;
     CarSelector.OnCarChanged += CarSelector_OnCarChanged;
     _handler = HistoryHandler.Instance;
     _handler.LoadCompleted += Instance_LoadCompleted;
     _handler.DayRefreshed  += Instance_DayRefreshed;
     _handler.OBDLoaded     += Instance_OBDLoaded;
     _handler.AccLoaded     += Instance_AccLoaded;
     _handler.DayChange     += _handler_DayChange;
 }
Пример #5
0
        /**
         * Handles the exit buttons operations.
         */
        public static void ExitHandler()
        {
            string autoStart = SettingsHandler.GetSetting("autoStart");

            if (!autoStart.Equals("1"))
            {
                HistoryHandler.RevertChanges();
                StopSpecialAddonListeners();
                SettingsHandler.SetSetting("started", "0");
            }

            Application.Exit();
        }
Пример #6
0
        /**
         * Copies the config files from the target sim to the source sim.
         */
        public static bool CopyTargetSimFilesToSource()
        {
            SimulatorOption sourceOption = MainFormHandler.GetSelectedSourceSimulator();
            SimulatorOption targetOption = MainFormHandler.GetSelectedTargetSimulator();

            if (sourceOption == null || targetOption == null)
            {
                return(false);
            }

            CreateTargetSimulatorBackup();
            CreateSourceSimulatorBackup();

            string sourceAppDataFolder     = sourceOption.GetAppDataPath(true);
            string sourceProgramDataFolder = sourceOption.GetProgramDataPath(true);
            string targetAppDataFolder     = targetOption.GetAppDataPath(true);
            string targetProgramDataFolder = targetOption.GetProgramDataPath(true);

            foreach (string configFile in configFiles)
            {
                string sourceConfigFile = configFile;

                //Handling Prepar3d.CFG and FSX.CFG files.
                if (configFile.Equals(targetOption.GetSimConfigFile()))
                {
                    sourceConfigFile = sourceOption.GetSimConfigFile();
                }

                try
                {
                    if (File.Exists(targetAppDataFolder + "\\" + configFile))
                    {
                        File.Copy(targetAppDataFolder + "\\" + configFile, sourceAppDataFolder + "\\" + sourceConfigFile, true);
                    }

                    if (File.Exists(targetProgramDataFolder + "\\" + configFile))
                    {
                        File.Copy(targetProgramDataFolder + "\\" + configFile, sourceProgramDataFolder + "\\" + sourceConfigFile, true);
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError("Could not copy file, function copyTargetSimFilesToSource() - " + e.ToString());
                    continue;
                }
            }

            HistoryHandler.AppendHistory("3," + sourceOption.GetValue());

            return(true);
        }
        public void AddHandler(HistoryHandler handler)
        {
            handler.ActionPush += (sender, action) => {
                if (!_acceptNew)
                {
                    return;
                }

                _history.Push(action);
                _future.Clear();
                CanRedo = false;
                CanUndo = true;
            };
        }
Пример #8
0
 public HistoryWorkViewModel(System.Windows.Threading.Dispatcher dispatcher)
 {
     _dispatcher   = dispatcher;
     _tableHistory = new HistoryRowsViewModel(dispatcher);
     _tableHistory.PropertyChanged += _tableHistory_PropertyChanged;
     _handler = HistoryHandler.Instance;
     CarSelector.OnCarChanged += CarSelector_OnCarChanged;
     _handler.LoadCompleted   += Instance_LoadCompleted;
     _handler.DayRefreshed    += Instance_DayRefreshed;
     _handler.LinesLoaded     += Instance_LinesLoaded;
     _handler.OBDLoaded       += Instance_OBDLoaded;
     _handler.AccLoaded       += Instance_AccLoaded;
     _handler.DayChange       += _handler_DayChange;
 }
Пример #9
0
        /**
         * Handles the start migration button's functionality.
         */
        public static void StartMigrationHandler()
        {
            string isStarted = SettingsHandler.GetSetting("started");

            if (isStarted.Equals("1"))
            {
                if (HistoryHandler.RevertChanges())
                {
                    SettingsHandler.SetSetting("started", "0");
                    startMigrateButton.Text = START_MIGRATION_TEXT;
                    EnableMigrationCombos();
                    StopSpecialAddonListeners();
                }
                else
                {
                    MessageBox.Show("An error has occured, please try again or contact the developer for support.");
                }
            }
            else
            {
                DisableMigrationCombos();

                if (!FileListeners.InitStaticListeners())
                {
                    HistoryHandler.RevertChanges();
                    MessageBox.Show("An error has occured, please try again or contact the developer for support.");
                    EnableMigrationCombos();

                    return;
                }

                if (!RegistryHandler.SetSourceAsTarget())
                {
                    FileListeners.RemoveListeners();
                    HistoryHandler.RevertChanges();
                    MessageBox.Show("An error has occured, please try again or contact the developer for support.");
                    EnableMigrationCombos();

                    return;
                }

                StartSpecialAddonListeners();

                FilesHandler.CreateFakeFsxExecutable(GetSelectedTargetSimulator().GetSimPath());

                startMigrateButton.Text = STOP_MIGRATION_TEXT;
                SettingsHandler.SetSetting("started", "1");
            }
        }
Пример #10
0
 public CompilateReportViewModel(Dispatcher dispatcher)
 {
     _dispatcher            = dispatcher;
     _handler               = HistoryHandler.Instance;
     _handler.DayRefreshed += Instance_DayRefreshed;
     //_handler.OBDLoaded += Instance_OBDLoaded;
     CarSelector.OnCarChanged += CarSelector_OnCarChanged;
     if (CarSelector.SelectedCar != null)
     {
         CarNumber = CarSelector.SelectedCar.Car.CarNumber;
     }
     if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         return;
     }
     //HistoryRows.Add(new HistoryCarStateViewModel {Date = DateTime.Now});
 }
Пример #11
0
        public Editor(World world, GraphicsDevice graphicsDevice)
        {
            _world    = world;
            _aabbTree = _world.AABBTree;
            _entities = _world.Entities;

            _historyHandler   = new HistoryHandler(null);
            _selectedEntities = new AABBTree <Entity>();

            _selection = new RectEdit();
            _edit      = new RectEdit();

            _ui = new IMGUI();

            _pathEditor = new PathEditor(_world.Woods);

            WindowResize(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);
        }
Пример #12
0
        /**
         * Sets the path of the source simulator as the target.
         */
        public static bool SetSourceAsTarget()
        {
            SimulatorOption sourceOption = MainFormHandler.GetSelectedSourceSimulator();
            SimulatorOption targetOption = MainFormHandler.GetSelectedTargetSimulator();

            if (sourceOption == null || targetOption == null)
            {
                return(false);
            }

            string targetPath    = targetOption.GetSimPath();
            int    registryIndex = 0;

            foreach (string registryPath in sourceOption.GetRegistryPaths())
            {
                string sourcePath = RegistryInterface.GetRegistryValue(registryPath);
                RegistryInterface.SetRegistryValue(registryPath, targetPath, true);

                string log = "";

                if (!sourcePath.Equals("") && sourcePath != null)
                {
                    log = "1," + sourceOption.GetValue() + "," + registryIndex + "," + sourcePath;
                }
                else
                {
                    log = "1," + sourceOption.GetValue() + "," + registryIndex + ",0";
                }

                HistoryHandler.AppendHistory(log);

                registryIndex++;
            }

            return(true);
        }
 public HistoryController(HistoryHandler handler)
 {
     this.handler = handler;
 }
Пример #14
0
 public EndBulkEditing(HistoryHandler historyHandler, string name)
 {
     this.historyHandler = historyHandler;
     this.name           = name;
 }