Exemple #1
0
        internal static void DragFile(object sender, FileDropEventArgs e)
        {
            int n = Files.Length;

            Array.Resize(ref Files, n + 1);
            Files[n] = e.FileName;
            // reset
            LightingRelative = -1.0;
            Game.Reset();
            RefreshObjects();
            Renderer.InitializeVisibility();
            Renderer.UpdateVisibility(0.0, true);
            ObjectManager.UpdateAnimatedWorldObjects(0.01, true);
            Renderer.ApplyBackgroundColor();
        }
Exemple #2
0
        internal static void DragFile(object sender, FileDropEventArgs e)
        {
            int n = Files.Length;

            Array.Resize <string>(ref Files, n + 1);
            Files[n] = e.FileName;
            // reset
            ReducedMode      = false;
            LightingRelative = -1.0;
            Game.Reset();
            Renderer.TextureManager.UnloadAllTextures();
            //Fonts.Initialize();
            Interface.ClearMessages();
            for (int i = 0; i < Files.Length; i++)
            {
#if !DEBUG
                try
                {
#endif
                if (String.Compare(System.IO.Path.GetFileName(Files[i]), "extensions.cfg", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    UnifiedObject[]    carObjects, bogieObjects, couplerObjects;
                    double[]           axleLocations, couplerDistances;
                    TrainManager.Train train;
                    ExtensionsCfgParser.ParseExtensionsConfig(Files[i], out carObjects, out bogieObjects, out couplerObjects, out axleLocations, out couplerDistances, out train, true);
                    double z = 0.0;
                    for (int j = 0; j < carObjects.Length; j++)
                    {
                        Renderer.CreateObject(carObjects[j], new Vector3(0.0, 0.0, z),
                                              new Transformation(), new Transformation(), true, 0.0, 0.0, 25.0,
                                              0.0);
                        if (j < train.Cars.Length - 1)
                        {
                            z -= (train.Cars[j].Length + train.Cars[j + 1].Length) / 2.0;
                            z -= couplerDistances[j];
                        }
                    }
                    z = 0.0;
                    int trainCar = 0;
                    for (int j = 0; j < bogieObjects.Length; j++)
                    {
                        Renderer.CreateObject(bogieObjects[j], new Vector3(0.0, 0.0, z + axleLocations[j]),
                                              new Transformation(), new Transformation(), true, 0.0, 0.0, 25.0,
                                              0.0);
                        j++;
                        Renderer.CreateObject(bogieObjects[j], new Vector3(0.0, 0.0, z + axleLocations[j]),
                                              new Transformation(), new Transformation(), true, 0.0, 0.0, 25.0,
                                              0.0);
                        if (trainCar < train.Cars.Length - 1)
                        {
                            z -= (train.Cars[trainCar].Length + train.Cars[trainCar + 1].Length) / 2.0;
                            z -= couplerDistances[trainCar];
                        }
                        trainCar++;
                    }
                    z = 0.0;
                    for (int j = 0; j < couplerObjects.Length; j++)
                    {
                        z -= train.Cars[j].Length / 2.0;
                        z -= couplerDistances[j] / 2.0;

                        Renderer.CreateObject(couplerObjects[j], new Vector3(0.0, 0.0, z),
                                              new Transformation(), new Transformation(), true, 0.0, 0.0, 25.0,
                                              0.0);

                        z -= couplerDistances[j] / 2.0;
                        z -= train.Cars[j + 1].Length / 2.0;
                    }
                }
                else
                {
                    UnifiedObject o;
                    Program.CurrentHost.LoadObject(Files[i], System.Text.Encoding.UTF8, out o);
                    Renderer.CreateObject(o, Vector3.Zero,
                                          new Transformation(), new Transformation(), true, 0.0, 0.0, 25.0,
                                          0.0);
                }
#if !DEBUG
            }
            catch (Exception ex)
            {
                Interface.AddMessage(MessageType.Critical, false,
                                     "Unhandled error (" + ex.Message + ") encountered while processing the file " +
                                     Files[i] + ".");
            }
#endif
            }
            Renderer.InitializeVisibility();
            Renderer.UpdateVisibility(0.0, true);
            ObjectManager.UpdateAnimatedWorldObjects(0.01, true);
            Renderer.ApplyBackgroundColor();
        }