RemoveControlRepeat() private static method

Removes a control repeat
private static RemoveControlRepeat ( int controlIndex ) : void
controlIndex int The control index to stop repeating
return void
Exemplo n.º 1
0
        internal static void LeaveCheck(Vector2 Point)
        {
            if (!Loading.SimulationSetup)
            {
                return;
            }

            if (World.CameraMode != CameraViewMode.Interior && World.CameraMode != CameraViewMode.InteriorLookAhead)
            {
                return;
            }

            TrainManager.Car Car = TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar];
            int add = Car.CarSections[0].CurrentAdditionalGroup + 1;

            if (add < Car.CarSections[0].Groups.Length)
            {
                TrainManager.TouchElement[] TouchElements = Car.CarSections[0].Groups[add].TouchElements;

                if (TouchElements != null)
                {
                    foreach (var TouchElement in TouchElements)
                    {
                        int o = TouchElement.Element.ObjectIndex;
                        ShowObjectSelection(o);
                    }

                    int[] SelectBuffer = new int[2048];

                    PickPre(SelectBuffer, Point, new Vector2(5));

                    RenderSceneSelection();

                    int PickedObjectIndex = PickPost(SelectBuffer);

                    foreach (var TouchElement in TouchElements)
                    {
                        int o = TouchElement.Element.ObjectIndex;
                        HideObjectSelection(o);
                        if (o == PickedObjectIndex)
                        {
                            Car.CarSections[0].CurrentAdditionalGroup = TouchElement.JumpScreenIndex;
                            Car.ChangeCarSection(TrainManager.CarSectionType.Interior);
                            if (TouchElement.SoundIndex >= 0 && TouchElement.SoundIndex < Car.Sounds.Touch.Length)
                            {
                                Sounds.SoundBuffer      Buffer   = Car.Sounds.Touch[TouchElement.SoundIndex].Buffer;
                                OpenBveApi.Math.Vector3 Position = Car.Sounds.Touch[TouchElement.SoundIndex].Position;
                                Sounds.PlaySound(Buffer, 1.0, 1.0, Position, TrainManager.PlayerTrain, TrainManager.PlayerTrain.DriverCar, false);
                            }
                        }

                        // HACK: Normally terminate the command issued once.
                        if (o == PickedObjectIndex || (PickedObjectIndex != PrePickedObjectIndex && o == PrePickedObjectIndex))
                        {
                            for (int i = 0; i < Interface.CurrentControls.Length; i++)
                            {
                                if (Interface.CurrentControls[i].Method != Interface.ControlMethod.Touch)
                                {
                                    continue;
                                }
                                bool EnableOption = false;
                                for (int j = 0; j < Translations.CommandInfos.Length; j++)
                                {
                                    if (Interface.CurrentControls[i].Command == Translations.CommandInfos[j].Command)
                                    {
                                        EnableOption = Translations.CommandInfos[j].EnableOption;
                                        break;
                                    }
                                }
                                if (TouchElement.Command == Interface.CurrentControls[i].Command)
                                {
                                    if (EnableOption && TouchElement.CommandOption != Interface.CurrentControls[i].Option)
                                    {
                                        continue;
                                    }
                                    Interface.CurrentControls[i].AnalogState  = 0.0;
                                    Interface.CurrentControls[i].DigitalState = Interface.DigitalControlState.Released;
                                    MainLoop.RemoveControlRepeat(i);
                                }
                            }
                        }
                    }
                }
            }
        }