public InputEventsFilterCollection(HostInterface hostInterface)
        {
            _hostInterface = hostInterface;

            // initialize filters

            _filters = new Dictionary <FilterKey, IInputEventsFilter>()
            {
                { FilterKey.FullBlock, new ExecutionBlockEventsFilter(HandleResultAction) },
                { FilterKey.Base, new BaseInputEventsFilter(HandleResultAction) },
                { FilterKey.Standard, new StandardInputEventsFilter(HandleResultAction) },
                { FilterKey.CommandExecutionPrompt, new CommandExecutionPromptEventsFilter(HandleResultAction) },
                { FilterKey.AutoComplete, new AutoCompleteInputEventsFilter(HandleResultAction) }
            };

            // initialize subscriptions

            _subscriptions = new List <Action <InputEventsFilterHandlerArgs> >();

            // wire up events

            _hostInterface.RTB.KeyDown  += rtb_KeyDown;
            _hostInterface.RTB.KeyUp    += rtb_KeyUp;
            _hostInterface.RTB.KeyPress += rtb_KeyPress;
            _hostInterface.OnCopy       += _hostInterface_OnCopy;
        }
Exemplo n.º 2
0
 protected TrainManagerBase(HostInterface host, BaseRenderer renderer, BaseOptions Options, FileSystem fileSystem)
 {
     currentHost    = host;
     Renderer       = renderer;
     CurrentOptions = Options;
     FileSystem     = fileSystem;
 }
Exemplo n.º 3
0
 internal TextureManager(HostInterface CurrentHost, BaseRenderer Renderer)
 {
     currentHost             = CurrentHost;
     RegisteredTextures      = new Texture[16];
     RegisteredTexturesCount = 0;
     renderer = Renderer;
 }
Exemplo n.º 4
0
 public MarkerStartEvent(double trackPositionDelta, AbstractMessage message, HostInterface Host)
 {
     this.TrackPositionDelta = trackPositionDelta;
     this.DontTriggerAnymore = false;
     this.Message            = message;
     this.currentHost        = Host;
 }
Exemplo n.º 5
0
        public void DispatchRequests()
        {
            dispatcherLocked = true;

            int cntr = 0;

            while (((HostInterface.InputStreams[currentStreamID].SubmissionQueue.Count - executingRequestsPerStream[currentStreamID]) < 1 ||
                    executingRequestsPerStream[currentStreamID] == RequestWindow) && cntr < streamCount)
            {
                currentStreamID = (currentStreamID + 1) % streamCount;
                cntr++;
            }
            if (cntr == streamCount)
            {
                dispatcherLocked = false;
                return;
            }
            LinkedListNode <IORequest> request = HostInterface.InputStreams[currentStreamID].HeadRequest;
            int possibleNumberofRequests       = (int)RequestWindow - (int)executingRequestsPerStream[currentStreamID];

            for (int reqCntr = 0; reqCntr < possibleNumberofRequests && request != null; reqCntr++)
            {
                executingRequestsPerStream[currentStreamID]++;
                HostInterface.InputStreams[currentStreamID].HeadRequest = request.Next;
                HostInterface.SegmentIORequestNoCache_Sprinkler(request.Value);
                FTL.IOScheduler.Schedule((uint)HostInterface.InputStreams[currentStreamID].PriorityClass, currentStreamID);
                request = HostInterface.InputStreams[currentStreamID].HeadRequest;
            }
            currentStreamID = (currentStreamID + 1) % streamCount;

            dispatcherLocked = false;
        }
Exemplo n.º 6
0
 public CarSection(HostInterface Host, ObjectType Type, bool visibleFromInterior, UnifiedObject Object = null)
 {
     currentHost         = Host;
     Groups              = new ElementsGroup[1];
     Groups[0]           = new ElementsGroup(Type);
     VisibleFromInterior = visibleFromInterior;
     if (Object is StaticObject)
     {
         StaticObject s = (StaticObject)Object;
         Groups[0].Elements    = new AnimatedObject[1];
         Groups[0].Elements[0] = new AnimatedObject(Host)
         {
             States       = new[] { new ObjectState(s) },
             CurrentState = 0
         };
         currentHost.CreateDynamicObject(ref Groups[0].Elements[0].internalObject);
     }
     else if (Object is AnimatedObjectCollection)
     {
         AnimatedObjectCollection a = (AnimatedObjectCollection)Object;
         Groups[0].Elements = new AnimatedObject[a.Objects.Length];
         for (int h = 0; h < a.Objects.Length; h++)
         {
             Groups[0].Elements[h] = a.Objects[h].Clone();
             currentHost.CreateDynamicObject(ref Groups[0].Elements[h].internalObject);
         }
     }
 }
Exemplo n.º 7
0
        public CarSound(HostInterface currentHost, string trainFolder, string configurationFile, int currentLine, string soundFile, double radius, Vector3 position)
        {
            if (soundFile.Length == 0 || Path.ContainsInvalidChars(soundFile))
            {
                currentHost.AddMessage(MessageType.Error, false, "FileName contains illegal characters or is empty at line " + (currentLine + 1) + " in file " + configurationFile);
                return;
            }

            string absolutePathTosoundFile = Path.CombineFile(trainFolder, soundFile);

            if (!System.IO.File.Exists(absolutePathTosoundFile))
            {
                if (configurationFile != string.Empty)
                {
                    //Only add missing file message for BVE4 / XML sound configs, not default
                    currentHost.AddMessage(MessageType.Error, false, "The SoundFile " + soundFile + " was not found at line " + (currentLine + 1) + " in file " + configurationFile);
                }
                return;
            }
            SoundHandle handle;

            currentHost.RegisterSound(absolutePathTosoundFile, radius, out handle);
            Buffer        = handle as SoundBuffer;
            this.Position = position;
        }
Exemplo n.º 8
0
 public TextureMessage(HostInterface Host)
 {
     currentHost = Host;
     Timeout     = 10000;
     TriggerOnce = true;
     Direction   = MessageDirection.Forwards;
 }
Exemplo n.º 9
0
 public StationEndEvent(HostInterface Host, CurrentRoute CurrentRoute, double TrackPositionDelta, int StationIndex) : base(TrackPositionDelta)
 {
     currentHost        = Host;
     currentRoute       = CurrentRoute;
     DontTriggerAnymore = false;
     this.StationIndex  = StationIndex;
 }
Exemplo n.º 10
0
 public MarkerStartEvent(double TrackPositionDelta, AbstractMessage Message, HostInterface Host)
 {
     this.TrackPositionDelta = TrackPositionDelta;
     DontTriggerAnymore      = false;
     message     = Message;
     currentHost = Host;
 }
Exemplo n.º 11
0
        public override void Initialize(HostInterface CurrentHost, BaseOptions CurrentOptions)
        {
            base.Initialize(CurrentHost, CurrentOptions);

            try
            {
                if (pickingShader == null)
                {
                    pickingShader = new Shader(this, "default", "picking", true);
                }
                pickingShader.Activate();
                pickingShader.Deactivate();
            }
            catch
            {
                Interface.AddMessage(MessageType.Error, false, "Initializing the touch shader failed- Falling back to legacy openGL.");
                Interface.CurrentOptions.IsUseNewRenderer = false;
                ForceLegacyOpenGL = true;
            }

            events               = new Events(this);
            overlays             = new Overlays(this);
            Touch                = new Touch(this);
            ObjectsSortedByStart = new int[] { };
            ObjectsSortedByEnd   = new int[] { };
            Program.FileSystem.AppendToLogFile("Renderer initialised successfully.");
        }
Exemplo n.º 12
0
        public CurrentRoute(HostInterface host, BaseRenderer renderer)
        {
            currentHost   = host;
            this.renderer = renderer;

            Tracks = new Dictionary <int, Track>();
            Track t = new Track()
            {
                Elements = new TrackElement[0]
            };

            Tracks.Add(0, t);
            Sections = new Section[0];
            Stations = new RouteStation[0];
            BogusPreTrainInstructions = new BogusPreTrainInstruction[0];
            PointsOfInterest          = new PointOfInterest[0];
            CurrentBackground         = new StaticBackground(null, 6, false);
            TargetBackground          = new StaticBackground(null, 6, false);
            NoFogStart                 = 800.0f;
            NoFogEnd                   = 1600.0f;
            PreviousFog                = new Fog(NoFogStart, NoFogEnd, Color24.Grey, 0.0);
            CurrentFog                 = new Fog(NoFogStart, NoFogEnd, Color24.Grey, 0.5);
            NextFog                    = new Fog(NoFogStart, NoFogEnd, Color24.Grey, 1.0);
            Atmosphere                 = new Atmosphere();
            SecondsSinceMidnight       = 0.0;
            Information                = new RouteInformation();
            Illustrations.CurrentRoute = this;
        }
Exemplo n.º 13
0
        public override void Initialize(HostInterface CurrentHost, BaseOptions CurrentOptions)
        {
            base.Initialize(CurrentHost, CurrentOptions);

            redAxisVAO   = RegisterBox(Color128.Red);
            greenAxisVAO = RegisterBox(Color128.Green);
            blueAxisVAO  = RegisterBox(Color128.Blue);
        }
Exemplo n.º 14
0
 public StationEndEvent(double TrackPositionDelta, int StationIndex, CurrentRoute Route, HostInterface Host)
 {
     this.TrackPositionDelta = TrackPositionDelta;
     this.DontTriggerAnymore = false;
     this.StationIndex       = StationIndex;
     this.Route       = Route;
     this.currentHost = Host;
 }
Exemplo n.º 15
0
 internal TextureManager(HostInterface CurrentHost, BaseRenderer Renderer)
 {
     currentHost             = CurrentHost;
     RegisteredTextures      = new Texture[16];
     RegisteredTexturesCount = 0;
     renderer         = Renderer;
     animatedTextures = new Dictionary <TextureOrigin, Texture>();
 }
Exemplo n.º 16
0
        public CarSound(HostInterface currentHost, string soundFile, double radius, Vector3 position)
        {
            SoundHandle handle;

            currentHost.RegisterSound(soundFile, radius, out handle);
            Buffer        = handle as SoundBuffer;
            this.Position = position;
        }
Exemplo n.º 17
0
 /// <summary>Called when the plugin is loaded.</summary>
 /// <param name="host">The host that loaded the plugin.</param>
 /// <param name="fileSystem"></param>
 /// <param name="Options"></param>
 /// <param name="rendererReference"></param>
 public override void Load(HostInterface host, FileSystem fileSystem, BaseOptions Options, object rendererReference)
 {
     CurrentHost         = host;
     FileSystem          = fileSystem;
     CurrentOptions      = Options;
     Parser.knownRoutes  = new Dictionary <string, RouteProperties>();
     Parser.knownModules = new List <string>();
     RoutePropertiesDatabaseParser.LoadRoutePropertyDatabase(ref Parser.knownRoutes, ref Parser.knownModules);
 }
Exemplo n.º 18
0
        public override void Initialize(HostInterface CurrentHost, BaseOptions CurrentOptions)
        {
            base.Initialize(CurrentHost, CurrentOptions);

            events               = new Events(this);
            overlays             = new Overlays(this);
            Touch                = new Touch(this);
            ObjectsSortedByStart = new int[] { };
            ObjectsSortedByEnd   = new int[] { };
        }
Exemplo n.º 19
0
        public OpsiClient(string opsiServerRpcEndpoint, string username, string password, bool ignoreInvalidCert = false)
        {
            _opsiHttpClient = new OpsiHttpClient(opsiServerRpcEndpoint, username, password, ignoreInvalidCert);

            BackendInterface  = new BackendInterface(_opsiHttpClient);
            DepotInterface    = new DepotInterface(_opsiHttpClient);
            HostInterface     = new HostInterface(_opsiHttpClient);
            ProductsInterface = new ProductsInterface(_opsiHttpClient);
            BackendInterface  = new BackendInterface(_opsiHttpClient);
        }
Exemplo n.º 20
0
 /// <summary>Called when the plugin is loaded.</summary>
 /// <param name="host">The host that loaded the plugin.</param>
 /// <param name="fileSystem"></param>
 /// <param name="Options"></param>
 /// <param name="trainManagerReference"></param>
 public override void Load(HostInterface host, FileSystem fileSystem, BaseOptions Options, object trainManagerReference)
 {
     CurrentHost    = host;
     FileSystem     = fileSystem;
     CurrentOptions = Options;
     if (trainManagerReference is TrainManagerBase)
     {
         TrainManager = (TrainManagerBase)trainManagerReference;
     }
 }
Exemplo n.º 21
0
 /// <summary>Creates a new empty object</summary>
 public StaticObject(HostInterface Host)
 {
     currentHost = Host;
     Mesh        = new Mesh
     {
         Faces     = new MeshFace[] { },
         Materials = new MeshMaterial[] { },
         Vertices  = new VertexTemplate[] { }
     };
 }
Exemplo n.º 22
0
 public override void Load(HostInterface host, FileSystem fileSystem, BaseOptions Options, object rendererReference)
 {
     currentHost    = host;
     FileSystem     = fileSystem;
     CurrentOptions = Options;
     if (rendererReference is BaseRenderer)
     {
         Renderer = rendererReference as BaseRenderer;
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// A function called when the plugin is loaded.
        /// </summary>
        /// <param name="fileSystem">The instance of FileSytem class</param>
        /// <returns>Whether the plugin has been loaded successfully.</returns>
        public bool Load(FileSystem fileSystem)
        {
            FileSystem = fileSystem;
            //HACK: In order to avoid meddling with a shipped interface (or making this field public and increasing the mess), let's grab it via reflection
            CurrentHost = (HostInterface)typeof(FileSystem).GetField("currentHost", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(fileSystem);

            if (loading)
            {
                InputTranslator.Load();
            }

            // Start thread for LibUsb-based controllers
            LibUsb.LibUsbThread = new Thread(LibUsb.LibUsbLoop);
            LibUsb.LibUsbThread.Start();

            // Initialize the array of button properties
            for (int i = 0; i < ButtonProperties.Length; i++)
            {
                ButtonProperties[i] = new ButtonProp();
            }

            // Load settings from the config file
            LoadConfig();

            // Create the config form
            configForm = new Config();

            // Define the list of commands
            // We allocate 50 slots per handle plus one slot per command
            int commandCount = Translations.CommandInfos.Length;

            Controls = new InputControl[100 + commandCount];
            // Brake notches
            for (int i = 0; i < 50; i++)
            {
                Controls[i].Command = Translations.Command.BrakeAnyNotch;
                Controls[i].Option  = i;
            }
            // Power notches
            for (int i = 50; i < 100; i++)
            {
                Controls[i].Command = Translations.Command.PowerAnyNotch;
                Controls[i].Option  = i - 50;
            }
            // Other commands
            for (int i = 0; i < commandCount; i++)
            {
                Controls[i + 100].Command = (Translations.Command)i;
            }

            // Configure the mappings for the buttons and notches
            ConfigureMappings();

            return(true);
        }
Exemplo n.º 24
0
        public override void Initialize(HostInterface CurrentHost, BaseOptions CurrentOptions)
        {
            base.Initialize(CurrentHost, CurrentOptions);

            if (!ForceLegacyOpenGL)
            {
                redAxisVAO   = new Cube(this, Color128.Red);
                greenAxisVAO = new Cube(this, Color128.Green);
                blueAxisVAO  = new Cube(this, Color128.Blue);
            }
        }
        public AutoCompleteController(HostInterface hostInterface)
        {
            _hostInterface = hostInterface;
            _hostInterface.RTB.LostFocus        += _rtb_LostFocus;
            _hostInterface.RTB.TextChanged      += _rtb_TextChanged;
            _hostInterface.RTB.SelectionChanged += _rtb_SelectionChanged;

            _provider = new AutoCompleteProvider(_hostInterface);

            _hostInterface.InputFilters.RegisterSubscription(HandleKeyInputResultAction);
        }
Exemplo n.º 26
0
 public override void Load(HostInterface host, FileSystem fileSystem, BaseOptions Options, object rendererReference)
 {
     currentHost    = host;
     FileSystem     = fileSystem;
     CurrentOptions = Options;
     // ReSharper disable once MergeCastWithTypeCheck
     if (rendererReference is BaseRenderer)
     {
         Renderer = (BaseRenderer)rendererReference;
     }
 }
Exemplo n.º 27
0
 public NVMeIODispatcherSimple(string id, FTL ftl, HostInterface HI, uint streamCount, uint requestWindow) : base(id, ftl, HI as HostInterfaceNVMe)
 {
     RequestWindow              = requestWindow;
     this.streamCount           = streamCount;
     executingRequestsPerStream = new uint[streamCount];
     for (int i = 0; i < streamCount; i++)
     {
         executingRequestsPerStream[i] = 0;
     }
     dispatcherLocked = false;
 }
Exemplo n.º 28
0
 /// <summary>
 /// The function that calls the plugin's load function
 /// </summary>
 /// <param name="index">The index number which can use the plugins</param>
 /// <param name="currentHost">A reference to the current host</param>
 public static void CallPluginLoad(int index, HostInterface currentHost)
 {
     if (index < 0 || index >= AvailablePlugins.Count || index >= AvailablePluginInfos.Count)
     {
         return;
     }
     if (AvailablePluginInfos[index].Status == PluginInfo.PluginStatus.Enable)
     {
         return;
     }
     AvailablePluginInfos[index].Status = AvailablePlugins[index].Load(FileSystem) ? PluginInfo.PluginStatus.Enable : PluginInfo.PluginStatus.Failure;
 }
Exemplo n.º 29
0
 /// <summary>Creates a new sound buffer</summary>
 /// <param name="host">The host application</param>
 /// <param name="path">The on-disk path to the sound to load</param>
 /// <param name="radius">The radius for this sound</param>
 internal SoundBuffer(HostInterface host, string path, double radius)
 {
     Origin               = new PathOrigin(path, host);
     Radius               = radius;
     Loaded               = false;
     OpenAlBufferName     = 0;
     _duration            = 0.0;
     InternalVolumeFactor = 0.5;
     Ignore               = false;
     PitchFunction        = null;
     VolumeFunction       = null;
 }
Exemplo n.º 30
0
 /// <param name="Host">The </param>
 /// <param name="TrackPositionDelta">The delta position of the sound within a track block.</param>
 /// <param name="SoundBuffer">The sound buffer to play.</param>
 /// <param name="PlayerTrainOnly">Defines whether this sound is played for the player's train only, or for player and AI trains</param>
 /// <param name="AllCars">Whether this triggers for all cars in a train</param>
 /// <param name="Once">Defines whether this sound repeats looped, or plays once</param>
 /// <param name="Dynamic">Whether this sound is dynamic (Attached to a train)</param>
 /// <param name="Position">The position of the sound relative to it's track location</param>
 /// <param name="Speed">The speed in km/h at which this sound is played at it's original pitch (Set to zero to play at original pitch at all times)</param>
 public SoundEvent(HostInterface Host, double TrackPositionDelta, SoundHandle SoundBuffer, bool PlayerTrainOnly, bool AllCars, bool Once, bool Dynamic, Vector3 Position, double Speed) : base(TrackPositionDelta)
 {
     this.currentHost        = Host;
     this.DontTriggerAnymore = false;
     this.SoundBuffer        = (SoundBuffer)SoundBuffer;
     this.PlayerTrainOnly    = PlayerTrainOnly;
     this.Once     = Once;
     this.Dynamic  = Dynamic;
     this.Position = Position;
     this.Speed    = Speed;
     this.AllCars  = AllCars;
 }
Exemplo n.º 31
0
 /// <summary>
 /// </summary>
 /// <param name="host">Technical name of the host.</param>
 /// <param name="groups">Host groups to add the host to. The host groups must have the groupid property defined.</param>
 /// <param name="interfaces">Interfaces to be created for the host.</param>
 public Create(string host, HostGroup.HostGroup[] groups, HostInterface.HostInterface[] interfaces)
     : base(host)
 {
     this.groups = groups;
     this.interfaces = interfaces;
 }
Exemplo n.º 32
0
 /// <summary>
 /// </summary>
 /// <param name="hosts">Hosts to be updated. The hosts must have the hostid property defined.</param>
 /// <param name="interfaces">Host interfaces to create on the given hosts.</param>
 public MassAdd(Host.Host[] hosts, HostInterface[] interfaces)
 {
     this.hosts = hosts;
     this.interfaces = interfaces;
 }
Exemplo n.º 33
0
 /// <summary>
 /// </summary>
 /// <param name="hostid">ID of the host to be updated.</param>
 /// <param name="interfaces">Host interfaces to replace the current host interfaces with.</param>
 public ReplaceHostInterfaces(string hostid, HostInterface[] interfaces)
 {
     this.hostid = hostid;
     this.interfaces = interfaces;
 }
Exemplo n.º 34
0
 /// <summary>
 /// </summary>
 /// <param name="hostids">IDs of the hosts to be updated.</param>
 /// <param name="interfaces">Host interfaces to remove from the given hosts.</param>
 public MassRemove(string[] hostids, HostInterface[] interfaces)
 {
     this.hostids = hostids;
     this.interfaces = interfaces;
 }