public virtual void Parse(string lowercasetoken, STFReader stf)
 {
     switch (lowercasetoken)
     {
     case "engine(ortselectrictrainsupply(mode":
         string text = stf.ReadStringBlock("").ToLower();
         if (text == "automatic")
         {
             Mode = ModeType.Automatic;
         }
         else if (text == "unfitted")
         {
             Mode = ModeType.Unfitted;
         }
         else if (text == "switch")
         {
             Mode = ModeType.Switch;
         }
         else
         {
             STFException.TraceWarning(stf, "Skipped invalid electric train supply switch mode");
         }
         break;
     }
 }
示例#2
0
        }                                                // true for humans

        public CarSpawnerList(STFReader stf, string shapePath, string listName)
        {
            ListName = listName;
            var count = stf.ReadInt(null);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("ignorexrotation", () => { IgnoreXRotation = stf.ReadBoolBlock(true); }),
                new STFReader.TokenProcessor("carspawneritem", () => {
                    if (--count < 0)
                    {
                        STFException.TraceWarning(stf, "Skipped extra CarSpawnerItem");
                    }
                    else
                    {
                        CarSpawner dataItem = new CarSpawner(stf, shapePath);
                        if (File.Exists(dataItem.Name))
                        {
                            Add(dataItem);
                        }
                        else
                        {
                            STFException.TraceWarning(stf, $"Non-existent shape file {dataItem.Name} referenced");
                        }
                    }
                }),
            });
            if (count > 0)
            {
                STFException.TraceWarning(stf, count + " missing CarSpawnerItem(s)");
            }
        }
示例#3
0
        static IDictionary <string, SignalDrawState> ReadDrawStates(STFReader stf)
        {
            stf.MustMatch("(");
            int count = stf.ReadInt(null);
            Dictionary <string, SignalDrawState> drawStates = new Dictionary <string, SignalDrawState>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signaldrawstate", () => {
                    if (drawStates.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalDrawState");
                    }
                    else
                    {
                        SignalDrawState drawState = new SignalDrawState(stf);
                        if (drawStates.ContainsKey(drawState.Name))
                        {
                            string TempNew = String.Copy("DST");
                            TempNew        = String.Concat(TempNew, drawStates.Count.ToString());
                            drawStates.Add(TempNew, drawState);
                            STFException.TraceInformation(stf, "Duplicate SignalDrawState name \'" + drawState.Name + "\', using name \'" + TempNew + "\' instead");
                        }
                        else
                        {
                            drawStates.Add(drawState.Name, drawState);
                        }
                    }
                }),
            });
            if (drawStates.Count < count)
            {
                STFException.TraceWarning(stf, (count - drawStates.Count).ToString() + " missing SignalDrawState(s)");
            }
            return(drawStates);
        }
示例#4
0
        private static IDictionary <string, LightTexture> ReadLightTextures(STFReader stf)
        {
            stf.MustMatch("(");
            int count = stf.ReadInt(null);
            Dictionary <string, LightTexture> lightTextures = new Dictionary <string, LightTexture>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("lighttex", () => {
                    if (lightTextures.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra LightTex");
                    }
                    else
                    {
                        LightTexture lightTexture = new LightTexture(stf);
                        if (lightTextures.ContainsKey(lightTexture.Name))
                        {
                            STFException.TraceWarning(stf, "Skipped duplicate LightTex " + lightTexture.Name);
                        }
                        else
                        {
                            lightTextures.Add(lightTexture.Name, lightTexture);
                        }
                    }
                }),
            });
            if (lightTextures.Count < count)
            {
                STFException.TraceWarning(stf, (count - lightTextures.Count).ToString() + " missing LightTex(s)");
            }
            return(lightTextures);
        }
示例#5
0
        private static IDictionary <string, LightTableEntry> ReadLightsTable(STFReader stf)
        {
            stf.MustMatch("(");
            int count = stf.ReadInt(null);
            Dictionary <string, LightTableEntry> lightsTable = new Dictionary <string, LightTableEntry>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("lightstabentry", () => {
                    if (lightsTable.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra LightsTabEntry");
                    }
                    else
                    {
                        LightTableEntry lightsTableEntry = new LightTableEntry(stf);
                        if (lightsTable.ContainsKey(lightsTableEntry.Name))
                        {
                            STFException.TraceWarning(stf, "Skipped duplicate LightsTabEntry " + lightsTableEntry.Name);
                        }
                        else
                        {
                            lightsTable.Add(lightsTableEntry.Name, lightsTableEntry);
                        }
                    }
                }),
            });
            if (lightsTable.Count < count)
            {
                STFException.TraceWarning(stf, (count - lightsTable.Count).ToString() + " missing LightsTabEntry(s)");
            }
            return(lightsTable);
        }
示例#6
0
        private static IDictionary <string, SignalShape> ReadSignalShapes(STFReader stf)
        {
            stf.MustMatch("(");
            int count = stf.ReadInt(null);
            Dictionary <string, SignalShape> signalShapes = new Dictionary <string, SignalShape>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signalshape", () => {
                    if (signalShapes.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalShape");
                    }
                    else
                    {
                        SignalShape signalShape = new SignalShape(stf);
                        if (signalShapes.ContainsKey(signalShape.ShapeFileName))
                        {
                            STFException.TraceWarning(stf, "Skipped duplicate SignalShape " + signalShape.ShapeFileName);
                        }
                        else
                        {
                            signalShapes.Add(signalShape.ShapeFileName, signalShape);
                        }
                    }
                }),
            });
            if (signalShapes.Count < count)
            {
                STFException.TraceWarning(stf, (count - signalShapes.Count).ToString() + " missing SignalShape(s)");
            }
            return(signalShapes);
        }
示例#7
0
        static IList <SignalSubObj> ReadSignalSubObjects(STFReader stf)
        {
            stf.MustMatch("(");
            int count = stf.ReadInt(null);
            List <SignalSubObj> signalSubObjects = new List <SignalSubObj>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signalsubobj", () => {
                    if (signalSubObjects.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalSubObj");
                    }
                    else
                    {
                        SignalSubObj signalSubObject = new SignalSubObj(stf);
                        if (signalSubObject.Index != signalSubObjects.Count)
                        {
                            STFException.TraceWarning(stf, "Invalid SignalSubObj index; expected " + signalSubObjects.Count + ", got " + signalSubObject.Index);
                        }
                        signalSubObjects.Add(signalSubObject);
                    }
                }),
            });
            if (signalSubObjects.Count < count)
            {
                STFException.TraceWarning(stf, (count - signalSubObjects.Count).ToString() + " missing SignalSubObj(s)");
            }
            return(signalSubObjects);
        }
示例#8
0
 public TurntableFile(string filePath, string shapePath, List <MovingTable> movingTables, Simulator simulator)
 {
     using (STFReader stf = new STFReader(filePath, false))
     {
         var count = stf.ReadInt(null);
         stf.ParseBlock(new STFReader.TokenProcessor[] {
             new STFReader.TokenProcessor("turntable", () => {
                 if (--count < 0)
                 {
                     STFException.TraceWarning(stf, "Skipped extra Turntable");
                 }
                 else
                 {
                     movingTables.Add(new Turntable(stf, simulator));
                 }
             }),
             new STFReader.TokenProcessor("transfertable", () => {
                 if (--count < 0)
                 {
                     STFException.TraceWarning(stf, "Skipped extra Transfertable");
                 }
                 else
                 {
                     movingTables.Add(new Transfertable(stf, simulator));
                 }
             }),
         });
         if (count > 0)
         {
             STFException.TraceWarning(stf, count + " missing Turntable(s)");
         }
     }
 }
示例#9
0
        public ClockList(STFReader stf, string shapePath)
        {
            var count = stf.ReadInt(null);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("clockitem", () => {
                    if (--count < 0)
                    {
                        STFException.TraceWarning(stf, "Skipped extra ClockItem");
                    }
                    else
                    {
                        var dataItem = new Clock(stf, shapePath);
                        if (File.Exists(dataItem.Name))
                        {
                            Add(dataItem);
                        }
                        else
                        {
                            STFException.TraceWarning(stf, $"Non-existent shape file {dataItem.Name} referenced");
                        }
                    }
                }),
            });
            if (count > 0)
            {
                STFException.TraceWarning(stf, count + " missing ClockItem(s)");
            }
        }
示例#10
0
        public virtual void Parse(string lowercasetoken, STFReader stf)
        {
            switch (lowercasetoken)
            {
            case "engine(ortsbattery(mode":
            case "wagon(ortsbattery(mode":
                string text = stf.ReadStringBlock("").ToLower();
                if (text == "alwayson")
                {
                    Mode = ModeType.AlwaysOn;
                }
                else if (text == "switch")
                {
                    Mode = ModeType.Switch;
                }
                else if (text == "pushbuttons")
                {
                    Mode = ModeType.PushButtons;
                }
                else
                {
                    STFException.TraceWarning(stf, "Skipped invalid battery switch mode");
                }
                break;

            case "engine(ortsbattery(delay":
            case "wagon(ortsbattery(delay":
                DelayS = stf.ReadFloatBlock(STFReader.UNITS.Time, 0f);
                break;
            }
        }
示例#11
0
        public ClockBlock(STFReader stf, string shapePath, List <ClockList> clockLists, string listName)
        {
            var clockDataItems = new List <ClockShape>();
            var count          = stf.ReadInt(null);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("clockitem", () => {
                    if (--count < 0)
                    {
                        STFException.TraceWarning(stf, "Skipped extra ClockItem");
                    }
                    else
                    {
                        var dataItem = new ClockShape(stf, shapePath);
                        if (File.Exists(shapePath + dataItem.Name))
                        {
                            clockDataItems.Add(dataItem);
                        }
                        else
                        {
                            STFException.TraceWarning(stf, String.Format("Non-existent shape file {0} referenced", dataItem.Name));
                        }
                    }
                }),
            });
            if (count > 0)
            {
                STFException.TraceWarning(stf, count + " missing ClockItem(s)");
            }
            ClockList clockList = new ClockList(clockDataItems, listName);

            clockLists.Add(clockList);
        }
示例#12
0
 public ORCarSpawnerFile(string fileName, string shapePath)
 {
     using (STFReader stf = new STFReader(fileName, false))
     {
         var    listCount = stf.ReadInt(null);
         string listName  = null;
         stf.ParseBlock(new STFReader.TokenProcessor[] {
             new STFReader.TokenProcessor("carspawnerlist", () => {
                 if (--listCount < 0)
                 {
                     STFException.TraceWarning(stf, "Skipped extra CarSpawner List");
                 }
                 else
                 {
                     stf.MustMatchBlockStart();
                     stf.MustMatch("ListName");
                     listName = stf.ReadStringBlock(null);
                     CarSpawners.Add(new CarSpawnerList(stf, shapePath, listName));
                 }
             }),
         });
         if (listCount > 0)
         {
             STFException.TraceWarning(stf, listCount + " missing CarSpawner List(s)");
         }
     }
 }
示例#13
0
        private List <SignalAspect> ReadAspects(STFReader stf)
        {
            stf.MustMatchBlockStart();
            int count = stf.ReadInt(null);
            List <SignalAspect> aspects = new List <SignalAspect>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signalaspect", () => {
                    if (aspects.Count >= aspects.Capacity)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalAspect");
                    }
                    else
                    {
                        SignalAspect aspect = new SignalAspect(stf);
                        if (aspects.Any(sa => sa.Aspect == aspect.Aspect))
                        {
                            STFException.TraceWarning(stf, "Skipped duplicate SignalAspect " + aspect.Aspect);
                        }
                        else
                        {
                            aspects.Add(aspect);
                        }
                    }
                }),
            });
            return(aspects);
        }
示例#14
0
        static List <SignalSubObject> ReadSignalSubObjects(STFReader stf)
        {
            stf.MustMatchBlockStart();
            int count = stf.ReadInt(null);
            List <SignalSubObject> signalSubObjects = new List <SignalSubObject>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signalsubobj", () => {
                    if (signalSubObjects.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalSubObj");
                    }
                    else
                    {
                        SignalSubObject signalSubObject = new SignalSubObject(stf);
                        if (signalSubObject.Index != signalSubObjects.Count)
                        {
                            STFException.TraceWarning(stf, $"Invalid SignalSubObj index; expected {signalSubObjects.Count}, got {signalSubObject.Index}");
                        }
                        signalSubObjects.Add(signalSubObject);
                    }
                }),
            });
            if (signalSubObjects.Count < count)
            {
                STFException.TraceWarning(stf, $"{(count - signalSubObjects.Count)} missing SignalSubObj(s)");
            }
            return(signalSubObjects);
        }
示例#15
0
        static List <SignalLight> ReadLights(STFReader stf)
        {
            stf.MustMatchBlockStart();
            int count = stf.ReadInt(null);
            List <SignalLight> lights = new List <SignalLight>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signallight", () => {
                    if (lights.Count >= lights.Capacity)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalLight");
                    }
                    else
                    {
                        lights.Add(new SignalLight(stf));
                    }
                }),
            });
            lights.Sort(SignalLight.Comparer);
            for (int i = 0; i < lights.Count; i++)
            {
                if (lights[i].Index != i)
                {
                    STFException.TraceWarning(stf, $"Invalid SignalLight index; expected {i}, got {lights[i].Index}");
                }
            }
            return(lights);
        }
示例#16
0
        private Dictionary <string, SignalDrawState> ReadDrawStates(STFReader stf)
        {
            stf.MustMatchBlockStart();
            int count = stf.ReadInt(null);
            Dictionary <string, SignalDrawState> drawStates = new Dictionary <string, SignalDrawState>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signaldrawstate", () => {
                    if (drawStates.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalDrawState");
                    }
                    else
                    {
                        SignalDrawState drawState = new SignalDrawState(stf);
                        if (drawStates.ContainsKey(drawState.Name))
                        {
                            string newState = $"DST{drawStates.Count}";
                            drawStates.Add(newState, drawState);
                            STFException.TraceInformation(stf, $"Duplicate SignalDrawState name \'{drawState.Name}\', using name \'{newState}\' instead");
                        }
                        else
                        {
                            drawStates.Add(drawState.Name, drawState);
                        }
                    }
                }),
            });
            if (drawStates.Count < count)
            {
                STFException.TraceWarning(stf, (count - drawStates.Count).ToString() + " missing SignalDrawState(s)");
            }
            return(drawStates);
        }
示例#17
0
        public static Interpolator CreateInterpolator(this STFReader reader)
        {
            List <double> list = new List <double>();

            reader.MustMatchBlockStart();
            while (!reader.EndOfBlock())
            {
                list.Add(reader.ReadFloat(STFReader.Units.Any, null));
            }
            if (list.Count % 2 == 1)
            {
                STFException.TraceWarning(reader, "Ignoring extra odd value in Interpolator list.");
            }
            int n = list.Count / 2;

            if (n < 2)
            {
                STFException.TraceWarning(reader, "Interpolator must have at least two value pairs.");
            }
            double[] xArray = new double[n];
            double[] yArray = new double[n];
            for (int i = 0; i < n; i++)
            {
                xArray[i] = list[2 * i];
                yArray[i] = list[2 * i + 1];
                if (i > 0 && xArray[i - 1] >= xArray[i])
                {
                    STFException.TraceWarning(reader, "Interpolator x values must be increasing.");
                }
            }
            return(new Interpolator(xArray, yArray));
        }
示例#18
0
 public WorldSoundRegion(STFReader stf, TrItem[] trItems)
 {
     TrackNodes = new List <int>();
     stf.MustMatch("(");
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("soundregiontracktype", () => { SoundRegionTrackType = stf.ReadIntBlock(-1); }),
         new STFReader.TokenProcessor("soundregionroty", () => { ROTy = stf.ReadFloatBlock(STFReader.UNITS.None, float.MaxValue); }),
         new STFReader.TokenProcessor("tritemid", () => {
             stf.MustMatch("(");
             var dummy    = stf.ReadInt(0);
             var trItemId = stf.ReadInt(-1);
             if (trItemId != -1)
             {
                 if (trItemId >= trItems.Length)
                 {
                     STFException.TraceWarning(stf, string.Format("Ignored invalid TrItemId {0}", trItemId));
                 }
                 else
                 {
                     TrackNodes.Add(trItemId);
                 }
             }
             stf.SkipRestOfBlock();
         }),
     });
 }
示例#19
0
        public virtual void Parse(string lowercasetoken, STFReader stf)
        {
            switch (lowercasetoken)
            {
            case "engine(ortsmasterkey(mode":
                string text = stf.ReadStringBlock("").ToLower();
                if (text == "alwayson")
                {
                    Mode = ModeType.AlwaysOn;
                }
                else if (text == "manual")
                {
                    Mode = ModeType.Manual;
                }
                else
                {
                    STFException.TraceWarning(stf, "Skipped invalid master key mode");
                }
                break;

            case "engine(ortsmasterkey(delayoff":
                DelayS = stf.ReadFloatBlock(STFReader.UNITS.Time, 0f);
                break;

            case "engine(ortsmasterkey(headlightcontrol":
                HeadlightControl = stf.ReadBoolBlock(false);
                break;
            }
        }
示例#20
0
        public static Interpolator2D CreateInterpolator2D(this STFReader stf)
        {
            List <double>       xlist = new List <double>();
            List <Interpolator> ilist = new List <Interpolator>();

            stf.MustMatchBlockStart();
            while (!stf.EndOfBlock())
            {
                xlist.Add(stf.ReadFloat(STFReader.Units.Any, null));
                ilist.Add(stf.CreateInterpolator());
            }
            stf.SkipRestOfBlock();
            int n = xlist.Count;

            if (n < 2)
            {
                STFException.TraceWarning(stf, "Interpolator must have at least two x values.");
            }
            double[]       xArray = new double[n];
            Interpolator[] yArray = new Interpolator[n];
            for (int i = 0; i < n; i++)
            {
                xArray[i] = xlist[i];
                yArray[i] = ilist[i];
                if (i > 0 && xArray[i - 1] >= xArray[i])
                {
                    STFException.TraceWarning(stf, " Interpolator x values must be increasing.");
                }
            }
            return(new Interpolator2D(xArray, yArray));
        }
示例#21
0
        public Interpolator(STFReader stf)
        {
            List <float> list = new List <float>();

            stf.MustMatch("(");
            while (!stf.EndOfBlock())
            {
                list.Add(stf.ReadFloat(STFReader.UNITS.Any, null));
            }
            if (list.Count % 2 == 1)
            {
                STFException.TraceWarning(stf, "Ignoring extra odd value in Interpolator list.");
            }
            int n = list.Count / 2;

            if (n < 2)
            {
                STFException.TraceWarning(stf, "Interpolator must have at least two value pairs.");
            }
            X    = new float[n];
            Y    = new float[n];
            Size = n;
            for (int i = 0; i < n; i++)
            {
                X[i] = list[2 * i];
                Y[i] = list[2 * i + 1];
                if (i > 0 && X[i - 1] >= X[i])
                {
                    STFException.TraceWarning(stf, "Interpolator x values must be increasing.");
                }
            }
        }
示例#22
0
        public Interpolator2D(STFReader stf)
        {
            List <float>        xlist = new List <float>();
            List <Interpolator> ilist = new List <Interpolator>();

            stf.MustMatch("(");
            while (!stf.EndOfBlock())
            {
                xlist.Add(stf.ReadFloat(STFReader.UNITS.Any, null));
                ilist.Add(new Interpolator(stf));
            }
            stf.SkipRestOfBlock();
            int n = xlist.Count;

            if (n < 2)
            {
                STFException.TraceWarning(stf, "Interpolator must have at least two x values.");
            }
            X    = new float[n];
            Y    = new Interpolator[n];
            Size = n;
            for (int i = 0; i < n; i++)
            {
                X[i] = xlist[i];
                Y[i] = ilist[i];
                if (i > 0 && X[i - 1] >= X[i])
                {
                    STFException.TraceWarning(stf, " Interpolator x values must be increasing.");
                }
            }
        }
示例#23
0
 internal WorldSoundRegion(STFReader stf, TrackItem[] trItems)
 {
     TrackNodes = new List <int>();
     stf.MustMatchBlockStart();
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("soundregiontracktype", () => { TrackType = stf.ReadIntBlock(-1); }),
         new STFReader.TokenProcessor("soundregionroty", () => { RotY = stf.ReadFloatBlock(STFReader.Units.None, float.MaxValue); }),
         new STFReader.TokenProcessor("tritemid", () => {
             stf.MustMatchBlockStart();
             stf.ReadInt(0);//dummy read
             int trItemId = stf.ReadInt(-1);
             if (trItemId != -1)
             {
                 if (trItemId >= trItems.Length)
                 {
                     STFException.TraceWarning(stf, $"Ignored invalid TrItemId {trItemId}");
                 }
                 else
                 {
                     TrackNodes.Add(trItemId);
                 }
             }
             stf.SkipRestOfBlock();
         }),
     });
 }
示例#24
0
        public CarSpawnerBlock(STFReader stf, string shapePath, List <CarSpawnerList> carSpawnerLists, string listName)
        {
            var spawnerDataItems = new List <CarSpawnerItemData>();
            {
                var count = stf.ReadInt(null);
                stf.ParseBlock(new STFReader.TokenProcessor[] {
                    new STFReader.TokenProcessor("carspawneritem", () => {
                        if (--count < 0)
                        {
                            STFException.TraceWarning(stf, "Skipped extra CarSpawnerItem");
                        }
                        else
                        {
                            var dataItem = new CarSpawnerItemData(stf, shapePath);
                            if (File.Exists(dataItem.name))
                            {
                                spawnerDataItems.Add(dataItem);
                            }
                            else
                            {
                                STFException.TraceWarning(stf, String.Format("Non-existent shape file {0} referenced", dataItem.name));
                            }
                        }
                    }),
                });
                if (count > 0)
                {
                    STFException.TraceWarning(stf, count + " missing CarSpawnerItem(s)");
                }
            }

            CarSpawnerList carSpawnerList = new CarSpawnerList(spawnerDataItems, listName);

            carSpawnerLists.Add(carSpawnerList);
        }
示例#25
0
 public SpeedpostDatFile(string filePath, string shapePath)
 {
     using (STFReader stf = new STFReader(filePath, false))
     {
         stf.ParseBlock(new STFReader.TokenProcessor[] {
             new STFReader.TokenProcessor("speed_warning_sign_shape", () =>
             {
                 var dataItem = stf.ReadStringBlock(null);
                 if (dataItem != null)
                 {
                     dataItem = shapePath + dataItem;
                     if (File.Exists(dataItem))
                     {
                         TempSpeedShapeNames[0] = dataItem;
                     }
                     else
                     {
                         STFException.TraceWarning(stf, String.Format("Non-existent shape file {0} referenced", dataItem));
                     }
                 }
             }
                                          ),
             new STFReader.TokenProcessor("restricted_shape", () =>
             {
                 var dataItem = stf.ReadStringBlock(null);
                 if (dataItem != null)
                 {
                     dataItem = shapePath + dataItem;
                     if (File.Exists(dataItem))
                     {
                         TempSpeedShapeNames[1] = dataItem;
                     }
                     else
                     {
                         STFException.TraceWarning(stf, String.Format("Non-existent shape file {0} referenced", dataItem));
                     }
                 }
             }
                                          ),
             new STFReader.TokenProcessor("end_restricted_shape", () =>
             {
                 var dataItem = stf.ReadStringBlock(null);
                 if (dataItem != null)
                 {
                     dataItem = shapePath + dataItem;
                     if (File.Exists(dataItem))
                     {
                         TempSpeedShapeNames[2] = dataItem;
                     }
                     else
                     {
                         STFException.TraceWarning(stf, String.Format("Non-existent shape file {0} referenced", dataItem));
                     }
                 }
             }
                                          ),
         });
     }
 }
示例#26
0
文件: Track.cs 项目: Reve/ORTS-MG
 private void Add(STFReader stf, TrackShape trackShape)
 {
     if (ContainsKey(trackShape.ShapeIndex))
     {
         STFException.TraceWarning(stf, "Replaced duplicate TrackShape " + trackShape.ShapeIndex);
     }
     this[trackShape.ShapeIndex] = trackShape;
 }
示例#27
0
文件: Track.cs 项目: Reve/ORTS-MG
 private void AddSection(STFReader stf, TrackSection section)
 {
     if (ContainsKey(section.SectionIndex))
     {
         STFException.TraceWarning(stf, "Replaced existing TrackSection " + section.SectionIndex);
     }
     this[section.SectionIndex] = section;
 }
示例#28
0
文件: Track.cs 项目: Reve/ORTS-MG
 private void AddPath(STFReader stf, TrackPath path)
 {
     try
     {
         Add(path.DynamicSectionIndex, path);
     }
     catch (Exception e)
     {
         STFException.TraceWarning(stf, "Warning: in route tsection.dat " + e.Message);
     }
 }
示例#29
0
 public ActivityFile(string fileName)
 {
     using (STFReader stf = new STFReader(fileName, false)) {
         stf.ParseFile(new STFReader.TokenProcessor[] {
             new STFReader.TokenProcessor("tr_activity", () => { Activity = new Activity(stf); }),
         });
         if (Activity == null)
         {
             STFException.TraceWarning(stf, "Missing Tr_Activity statement");
         }
     }
 }
示例#30
0
        protected void ParsePosition(STFReader stf)
        {
            stf.MustMatchBlockStart();
            bounds = new Rectangle(stf.ReadInt(null), stf.ReadInt(null), stf.ReadInt(null), stf.ReadInt(null));

            // skipping additional values in between
            while (!stf.EndOfBlock())
            {
                STFException.TraceWarning(stf, "Ignored additional positional parameters");
                bounds.Width  = bounds.Height;
                bounds.Height = stf.ReadInt(null);
            }
        }