Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        // load route
        internal static bool LoadRoute(Bitmap bitmap = null)
        {
            if (string.IsNullOrEmpty(CurrentRouteFile))
            {
                return(false);
            }
            CurrentStation = -1;
            Renderer.UpdateViewport();
            bool result;

            try
            {
                Encoding encoding = TextEncoding.GetSystemEncodingFromFile(CurrentRouteFile);
                Loading.Load(CurrentRouteFile, encoding, bitmap);
                result = true;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                Game.Reset();
                result           = false;
                CurrentRouteFile = null;
            }

            if (Loading.Cancel)
            {
                result           = false;
                CurrentRouteFile = null;
            }
            Renderer.Lighting.Initialize();
            Renderer.InitializeVisibility();
            return(result);
        }
Ejemplo n.º 3
0
        // load route
        internal static bool LoadRoute()
        {
            CurrentStation = -1;
            Game.Reset();
            Renderer.UpdateViewport();
            bool result;

            try {
                Loading.Load(CurrentRouteFile, System.Text.Encoding.UTF8);
                result = true;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                Game.Reset();
                CurrentRoute = null;
                result       = false;
            }
            Renderer.Lighting.Initialize();
            Renderer.InitializeVisibility();
            Renderer.TextureManager.UnloadAllTextures();
            return(result);
        }
Ejemplo n.º 4
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();
        }