Exemple #1
0
 void Dispose(bool manual)
 {
     if (!disposed)
     {
         lock (sync)
         {
             if (manual)
             {
                 Debug.Print("Disposing {0}", GetType());
                 InputDriver.Dispose();
                 if (Exists)
                 {
                     DestroyWindow();
                 }
             }
             else
             {
                 Debug.WriteLine("Sdl2NativeWindow leaked, did you forget to call Dispose()?");
                 if (Exists)
                 {
                     // If the main loop is still running, send a close message.
                     // This will raise the Closing/Closed events and then destroy
                     // the window.
                     // Todo: it is probably not safe to raise events once the
                     // finalizer has run. Review this.
                     Close();
                 }
             }
             disposed = true;
         }
     }
 }
Exemple #2
0
        public override void Execute(ActivityContext context)
        {
            var query = ElementQuery.Get(this.Element);

            if (query == null)
            {
                return;
            }

            var elements = WinContext.Shared.GetElementsFromQuery(query);

            if (elements.Count() == 0)
            {
                throw new Exception("Element not found.");
            }
            if (elements.Count() > 1)
            {
                throw new Exception("Too many elements found.");
            }

            using (var input = new InputDriver())
            {
                var e = elements.First() as WinElement;
                e.Focus();
                e.Click();
            }
        }
        public void SetPort(PlatformId platform, int portNumber, ControllerId controller,
                            Guid deviceInstanceGuid, InputDriver instanceDriver, Guid inputProfile, string emulatorName)
        {
            using var context = new DatabaseContext(Options.Options);
            var entity = context.PortDeviceEntries
                         .Find(emulatorName, platform, portNumber);

            if (entity != null)
            {
                entity.ProfileGuid          = inputProfile;
                entity.InstanceGuid         = deviceInstanceGuid;
                entity.ControllerID         = controller;
                entity.Driver               = instanceDriver;
                context.Entry(entity).State = EntityState.Modified;
            }
            else
            {
                var newEntity = new PortDeviceEntryModel()
                {
                    ProfileGuid      = inputProfile,
                    InstanceGuid     = deviceInstanceGuid,
                    ControllerID     = controller,
                    Driver           = instanceDriver,
                    OrchestratorName = emulatorName,
                    PlatformID       = platform,
                    PortIndex        = portNumber
                };
                context.PortDeviceEntries.Add(newEntity);
            }
            context.SaveChanges();
        }
Exemple #4
0
        public MainWindow()
        {
            InitializeComponent();

            IDisplayDriver displayDriver = new DisplayDriver(this, myCanvas);
            IInputDriver   inputDriver   = new InputDriver(this);

            myGame = new DummyGame(displayDriver, inputDriver);
        }
        public void AssignDriverToVehicle()
        {
            int driverId, vehicleId;

            driverId  = InputDriver.CatchDriverId();
            vehicleId = InputVehicle.CatchVehicleId();

            StandardMessage.ValidationSummary(Company.AssignDriverToVehicle(driverId, vehicleId));
        }
Exemple #6
0
        private void DrawPointingDirectionTriangle()
        {
            if (CurrentViewedTank == null || !CurrentViewedTank.Alive)
            {
                return;
            }
            //This code does exactly what it sounds like.
            //It draws an arrow to show which direction the cursor is pointing.
            //It's here because turning has a delayed rection (intentional) so we wanna
            //show where the turret is going to end up.

            //First, get the view rectangle
            var viewRect = ComputeDrawRectangle(CurrentViewedTank);

            //Begin drawing in that area
            //_spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null,
            //   Matrix.CreateOrthographicOffCenter(viewRect.Left, viewRect.Right, viewRect.Bottom, viewRect.Top, -1, 1));

            var tankPos   = CurrentViewedTank.Position;
            var lookPoint = InputDriver.GetInputState().LookDirection - MathHelper.PiOver2;

            //Check if we're spectating
            if (CurrentViewedTank != Client?.Player?.Tank)
            {
                lookPoint = CurrentViewedTank.InputState.LookDirection - MathHelper.PiOver2;
            }

            //Radius of circle = 5
            //And solve the triangle
            var cursorPos = new Vector2(
                5f * (float)Math.Cos(lookPoint),
                5f * (float)Math.Sin(lookPoint)
                ) + tankPos;

            //
            //     0,.5
            //
            //-0.5,-.5|0,-0.5|.5,-.5
            //Triangle points
            var pts = new[] {
                new Vector2(0, 0.5f),
                new Vector2(-0.5f),
                new Vector2(.5f, -.5f)
            };

            pts = pts.Select(a => RotatePoint(a, lookPoint - MathHelper.PiOver2, Vector2.Zero) + cursorPos).ToArray();

            _fx.Alpha = 0.33f;
            _fx.VertexColorEnabled = true;
            _fx.World = Matrix.CreateOrthographicOffCenter(viewRect.Left, viewRect.Right, viewRect.Bottom, viewRect.Top, -1, 1);
            foreach (var pass in _fx.CurrentTechnique.Passes)
            {
                pass.Apply();
                var vpc = pts.Select(a => new VertexPositionColor(new Vector3(a, 0), Color.Red)).ToArray();
                GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vpc, 0, 1);
            }
        }
Exemple #7
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            ;
            InputDriver.Poll();

            mouse = OpenTK.Input.Mouse.GetState();
            if (mouse != mouse_old)
            {
                refresh_text = true;
            }
            mouse_old = mouse;

            keyboard = OpenTK.Input.Keyboard.GetState();
            if (keyboard != keyboard_old)
            {
                refresh_text = true;
            }
            keyboard_old = keyboard;

            if (refresh_text)
            {
                refresh_text = false;

                using (Graphics gfx = Graphics.FromImage(TextBitmap))
                {
                    int line = 0;

                    gfx.Clear(Color.Black);
                    gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

                    DrawString(gfx, Context.GraphicsMode.ToString(), line++);

                    DrawString(gfx, String.Format("[1 - 4]: change WindowState (current: {0}).", this.WindowState), line++);
                    DrawString(gfx, String.Format("[5 - 7]: change WindowBorder (current: {0}).", this.WindowBorder), line++);
                    DrawString(gfx, String.Format("Focused: {0}.", this.Focused), line++);
                    DrawString(gfx, String.Format("Mouse {0} window.", mouse_in_window ? "inside" : "outside of"), line++);
                    DrawString(gfx, String.Format("Mouse visible: {0}", CursorVisible), line++);
                    DrawString(gfx, String.Format("Mouse position (absolute): {0}", new Vector3(Mouse.X, Mouse.Y, Mouse.Wheel)), line++);
                    DrawString(gfx, String.Format("Mouse position (relative): {0}", new Vector3(mouse.X, mouse.Y, mouse.WheelPrecise)), line++);
                    DrawString(gfx, String.Format("Window.Bounds: {0}", Bounds), line++);
                    DrawString(gfx, String.Format("Window.Location: {0}, Size: {1}", Location, Size), line++);
                    DrawString(gfx, String.Format("Window: {{X={0},Y={1},Width={2},Height={3}}}", X, Y, Width, Height), line++);
                    DrawString(gfx, String.Format("Window.ClientRectangle: {0}", ClientRectangle), line++);
                    DrawString(gfx, TypedText.ToString(), line++);
                    DrawKeyboard(gfx, keyboard, line++);
                    DrawMouse(gfx, mouse, line++);
                    DrawJoysticks(gfx, Joysticks, line++);
                }
            }

            System.Drawing.Imaging.BitmapData data = TextBitmap.LockBits(
                new System.Drawing.Rectangle(0, 0, TextBitmap.Width, TextBitmap.Height),
                System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, TextBitmap.Width, TextBitmap.Height, PixelFormat.Bgra,
                             PixelType.UnsignedByte, data.Scan0);
            TextBitmap.UnlockBits(data);
        }
Exemple #8
0
        public override void Execute(ActivityContext context)
        {
            var e = context.GetElement(this.Element);

            using (var input = new InputDriver())
            {
                e.Focus();
                e.Click();
            }
        }
 /// <summary>
 /// Initializes a <see cref="ControllerElementMappingProfile"/> from an <see cref="IDeviceLayoutMapping"/>,
 /// that includes all mappings from the default layout.
 /// </summary>
 /// <param name="deviceName">The name of the physical device for this set of mappings.</param>
 /// <param name="controllerId">The Stone <see cref="ControllerID"/> this mapping is intended for.</param>
 /// <param name="driver">The <see cref="InputDriver"/> of the device instance for this set of mappings.</param>
 /// <param name="vendor">The vendor ID of the physical device for this set of mappings.</param>
 /// <param name="mapping">The device layout mapping provided by the device enumerator.</param>
 /// <param name="profileGuid">The <see cref="Guid"/> of this mapping profile.</param>
 public ControllerElementMappingProfile(string deviceName,
                                        ControllerId controllerId, InputDriver driver, int vendor,
                                        IDeviceLayoutMapping mapping, Guid profileGuid)
     : this(deviceName, controllerId, driver, vendor, profileGuid)
 {
     foreach (var controllerElement in mapping)
     {
         this.Add(controllerElement);
     }
 }
 public ControllerElementMappingProfile(string deviceName,
                                        ControllerId controllerId, InputDriver driver, int vendor, Guid profileGuid)
 {
     this.DeviceName         = deviceName;
     this.ControllerID       = controllerId;
     this.DriverType         = driver;
     this.VendorID           = vendor;
     this.controllerElements = new Dictionary <ControllerElement, ControllerElementMapping>();
     this.ProfileGuid        = profileGuid;
 }
Exemple #11
0
        public override void Execute(ActivityContext context)
        {
            var e = context.GetElement(this.Element);

            using (var input = new InputDriver())
            {
                e.Focus();
                var p = e.Bounds.Center;
                input.MouseMove(p.X, p.Y);
                input.Click(MouseButton.Left);
            }
        }
Exemple #12
0
        public void Unregister()
        {
            _joystick.JoystickClicked -= OnJoystickClicked;

            if (_inputDriver == null)
            {
                return;
            }

            UserDriverManager.Manager.UnregisterInputDriver(_inputDriver);
            _inputDriver = null;
        }
Exemple #13
0
        protected virtual void Dispose(bool disposing)
        {
            Unregister();

            if (disposing)
            {
                _inputDriver?.Dispose();
                _joystick?.Dispose();

                _inputDriver = null;
                _joystick    = null;
            }
        }
        public override DictionaryInputMapping?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            using var jsonDoc = JsonDocument.ParseValue(ref reader);
            var         rootElem     = jsonDoc.RootElement;
            string?     driverString = rootElem.GetProperty("driver").GetString();
            InputDriver driver       = Enums.Parse <InputDriver>(driverString !);

            var controllerElements = rootElem.GetProperty("mappings").EnumerateObject()
                                     .Select(prop => (element: Enums.Parse <DeviceCapability>(prop.Name), value: prop.Value.GetString() !))
                                     .ToDictionary(o => o.element, o => o.value);

            return(new DictionaryInputMapping(driver, controllerElements));
        }
        public void SearchForDrivers()
        {
            if (Company.NumberOfHiredDrivers() > 0)
            {
                string firstName = InputDriver.CatchDriverFirstName();
                string lastName  = InputDriver.CatchDriverLastName();

                TryFindDrivers(Company.SearchForDrivers(firstName, lastName));
            }
            else
            {
                StandardMessage.NoDriversHired();
            }
        }
 /// <summary>
 /// Initializes a<see cref= "ControllerElementMappingProfile" /> from an <see cref="IDeviceLayoutMapping"/>,
 /// that includes only mappings that are assignable to the provided layout.
 /// </summary>
 /// <param name="deviceName">The name of the physical device for this set of mappings.</param>
 /// <param name="controller">The controller layout to assign device mappings to.</param>
 /// <param name="driver">The <see cref="InputDriver"/> of the device instance for this set of mappings.</param>
 /// <param name="vendor">The vendor ID of the physical device for this set of mappings.</param>
 /// <param name="mapping">The device layout mapping provided by the device enumerator.</param>
 /// <param name="profileGuid">The <see cref="Guid"/> of this mapping profile.</param>
 public ControllerElementMappingProfile(string deviceName,
                                        IControllerLayout controller, InputDriver driver, int vendor,
                                        IDeviceLayoutMapping mapping, Guid profileGuid)
     : this(deviceName, controller.ControllerID, driver, vendor, profileGuid)
 {
     foreach (var(controllerElement, _) in controller.Layout)
     {
         if (mapping[controllerElement] == DeviceCapability.None)
         {
             continue;
         }
         this.Add(new ControllerElementMapping(controllerElement, mapping[controllerElement]));
     }
 }
Exemple #17
0
        public void Register()
        {
            _joystick.JoystickClicked -= OnJoystickClicked;
            _joystick.JoystickClicked += OnJoystickClicked;

            if (_inputDriver != null)
            {
                return;
            }

            _inputDriver = new InputDriver.Builder((int)InputSourceType.ClassButton)
                           .SetName("SKRHABE010")
                           .SetKeys(_keyCodes.Cast <int>().ToArray())
                           .Build();
            UserDriverManager.Manager.RegisterInputDriver(_inputDriver);
        }
Exemple #18
0
    public void SetupVehicleManager()
    {
        //   Debug.LogWarning("Vehicle Health Manager has not been fully ported to the new PhysX system");
        gamestateTracker           = FindObjectOfType <GamestateTracker>();
        gamestateTrackerPhotonView = gamestateTracker.GetComponent <PhotonView>();
        networkManager             = FindObjectOfType <NetworkManager>();
        maxHealth        = health;
        rb               = GetComponent <PhysXRigidBody>();
        icd              = GetComponent <InterfaceCarDrive>();
        icd4             = GetComponent <InterfaceCarDrive4W>();
        carDriver        = icd.GetComponent <IDrivable>();
        inputDriver      = GetComponent <InputDriver>();
        myPhotonView     = GetComponent <PhotonView>();
        npv              = GetComponent <NetworkPlayerVehicle>();
        announcerManager = FindObjectOfType <AnnouncerManager>();



        _rammingDetails = new Weapon.WeaponDamageDetails(null, 0, 0, Weapon.DamageType.ramming, 0, Vector3.zero);

        for (int i = 0; i < collisionAreas.Count; i++)
        {
            CollisionArea collisionArea = collisionAreas[i];
            collisionArea.rotation.eulerAngles = collisionArea.rotationEuler;
            collisionAreas[i] = collisionArea;
        }

        defaultDrag            = rb.linearDamping;
        defaultAngularDrag     = rb.angularDamping;
        playerTransformTracker = FindObjectOfType <PlayerTransformTracker>();

        PlayerEntry player = gamestateTracker.players.Get((short)PhotonNetwork.LocalPlayer.ActorNumber);

        if (player.teamId == teamId)
        {
            tutorials.SetActive(true);
        }
        else
        {
            tutorials.SetActive(false);
        }
        player.Release();
    }
Exemple #19
0
        /// <summary>
        /// Put init logic here. Will be called after LoadContent()
        /// </summary>
        private void InitializeGame()
        {
            //Log in to ZSB Servers
            try
            { ZSB.DrmClient.Initialize(GlobalSettings.Instance.StoredAccountInfo); }
            catch
            { ZSB.DrmClient.Initialize(); } //If an error occurs, clear info and restart
            ZSB.DrmClient.OnPersistentStorageChanged +=
                (a, b) => GlobalSettings.Instance.StoredAccountInfo.Value = ZSB.DrmClient.PersistentData;
            //Handle fatal login errors
            if (!ZSB.DrmClient.LoggedIn && !GlobalSettings.Instance.NoLoginMode)
            {
                Logger.Fatal("Not logged in. Panicking at the disco. Did you launch the game executable by accident?");
                Exit();
                return;
            }

            _fx = new BasicEffect(GraphicsDevice);

            //Create the user interface
            _ui = new UserInterface(this);

            //Initialize the input driver from the configuration
            InputDriver = InputDriverBase.GetDriver(GameSettings.Instance.InputDriverName, this);
            if (GameSettings.Instance.InputKeyBindings.Value != null)
            {
                InputDriver.SetKeyBindings(GameSettings.Instance.InputKeyBindings);
            }

            ShowSetupPrompt();
            //Initialize renderers
            GameRenderer = new GameCoreRenderer(this, GameSettings.Instance.AssetSearchPaths, new[] { 0 }, new NLogLogger(Logger.Instance));
            SoundPlayer  = new SoundPlayer();
            //And, finally, Begin the async mod loading
            _modLoader      = AsyncModLoader.Create(GameSettings.Instance);
            _hasInitialized = true;
        }
Exemple #20
0
 public void Poll()
 {
     InputDriver.Poll();
 }
Exemple #21
0
 public Button(ButtonCode button, InputDriver driver)
 {
     code           = button;
     driver.Update += Driver_Update;
 }
Exemple #22
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>

        protected override void Update(GameTime gameTime)
        {
            _ui.Update(gameTime);
            SoundPlayer.Update(gameTime);

            if (!_hasInitialized || _closing)
            {
                return;
            }

            if (CurrentViewedTank != null && SoundPlayer != null)
            {
                SoundPlayer.PlayerPosition = CurrentViewedTank.Position;
                SoundPlayer.PlayerVelocity = CurrentViewedTank.LinearVelocity;
            }
            SoundPlayer?.Update(gameTime);

            Diagnostics.BeginMeasurement("Base.Update() & UI Update");
            base.Update(gameTime);
            Diagnostics.EndMeasurement("Base.Update() & UI Update");

            if (_modLoader.Running)
            {
                _ui.UpdateState(new
                {
                    Header  = "Loading mods...",
                    Content = _modLoader.Status,
                    Button  = "Cancel"
                });
                return;
            }
            else if (!_hasExecutedModLoaderInit)
            {
                _hasExecutedModLoaderInit = true;
                CreateGame();
                return;
            }
            if (!_isInPauseMenu)
            {
                InputDriver.Update(gameTime);
                var state = InputDriver.GetInputState();
                if (Client?.Input != null && state != Client.Input)
                {
                    Client.Input = state;
                }
            }

            if (AOTConfig.IsGameHost)
            {
                Server.Update(gameTime);
            }

            Client.Update(gameTime);
            if (Client?.Player?.Tank != null && Client.Player.Tank.Alive)
            {
                CurrentViewedTank = Client.Player.Tank;
            }

            if (_isInPauseMenu)
            {
                return; //Don't mess with the pause menu
            }
            if (Client.IsInTankSelection)
            {
                DeactivateGameInput();
                _ui.GoToPageIfNotThere("tankselectionpromptwithcountdown", page =>
                {
                    page.Element <Button>("UnReadyButton").Click += (a, b) =>
                    {
                        page.Element <Button>("ConfirmButton").Visibility         = EmptyKeys.UserInterface.Visibility.Visible;
                        page.Element <StackPanel>("tankselectionarea").Visibility = EmptyKeys.UserInterface.Visibility.Visible;
                        page.Element <StackPanel>("readyarea").Visibility         = EmptyKeys.UserInterface.Visibility.Collapsed;
                        Client.PlayerIsReady = false;
                    };
                    page.Element <Button>("ConfirmButton").Click += (a, b) =>
                    {
                        page.Element <Button>("ConfirmButton").Visibility         = EmptyKeys.UserInterface.Visibility.Collapsed;
                        page.Element <StackPanel>("tankselectionarea").Visibility = EmptyKeys.UserInterface.Visibility.Collapsed;
                        page.Element <StackPanel>("readyarea").Visibility         = EmptyKeys.UserInterface.Visibility.Visible;

                        Client.PlayerIsReady = true;
                    };
                }, (page, state) =>
                {
                    page.Element <TextBlock>("Subscript").Text =
                        page.State <double>("RemainingCountdown").ToString("N0") + " seconds remaining " +
                        (Client.PlayerIsReady ? "until start" : "to choose");

                    //And update tank options
                    var options = page.Element <StackPanel>("tankoptions");
                    if (page.State <string[]>("TankOptions") != null)
                    {
                        foreach (var opt in page.State <string[]>("TankOptions"))
                        {
                            if (options.Children.FirstOrDefault(a => a.Name == "opt_" + opt) != null)
                            {
                                //already in there
                                //so we do nothing
                            }
                            else
                            {
                                string reflectionName = opt; //Copy to avoid problems with closures
                                var info = Engine.Helpers.ReflectionHelper.GetGameObjectInfo(reflectionName);
                                if (!info.Exists)
                                {
                                    continue;               //If the type doesn't exist, continue without showing it
                                }
                                //not in there, so make it
                                var btn = new Button();
                                //Content is a stack panel
                                var stackPnl                 = new StackPanel();
                                stackPnl.Orientation         = EmptyKeys.UserInterface.Orientation.Vertical;
                                stackPnl.HorizontalAlignment = EmptyKeys.UserInterface.HorizontalAlignment.Stretch;
                                stackPnl.Children.Add(new TextBlock
                                {
                                    FontFamily          = new EmptyKeys.UserInterface.Media.FontFamily("JHUF"),
                                    FontSize            = 20,
                                    Foreground          = EmptyKeys.UserInterface.Media.Brushes.White,
                                    Text                = info.DisplayName,
                                    Margin              = new EmptyKeys.UserInterface.Thickness(0, 5, 0, 0),
                                    Width               = 350,
                                    HorizontalAlignment = EmptyKeys.UserInterface.HorizontalAlignment.Stretch
                                });
                                stackPnl.Children.Add(new TextBlock
                                {
                                    FontFamily          = new EmptyKeys.UserInterface.Media.FontFamily("JHUF"),
                                    FontSize            = 16,
                                    Foreground          = EmptyKeys.UserInterface.Media.Brushes.White,
                                    Margin              = new EmptyKeys.UserInterface.Thickness(0, 5, 0, 5),
                                    Text                = UserInterface.SplitStringIntoLines(info.DisplayDescription, 40),
                                    HorizontalAlignment = EmptyKeys.UserInterface.HorizontalAlignment.Center
                                });

                                btn.Background          = EmptyKeys.UserInterface.Media.Brushes.Gray;
                                btn.Content             = stackPnl;
                                btn.Name                = "opt_" + reflectionName;
                                btn.HorizontalAlignment = EmptyKeys.UserInterface.HorizontalAlignment.Center;
                                btn.Width               = 400;
                                btn.Click              += (a, b) =>
                                {
                                    options.Children.Select(c => (c as Button).Background = EmptyKeys.UserInterface.Media.Brushes.Transparent);
                                    btn.Background = EmptyKeys.UserInterface.Media.Brushes.Green;

                                    Client.SelectTank(reflectionName);
                                };
                                options.Children.Add(btn);
                            }
                        }
                    }
                });
                if (Client.Player != null)
                {
                    _ui.UpdateState(new
                    {
                        TankOptions        = Client.Player.AllowedTankTypes,
                        RemainingCountdown = Client.RemainingCountdownTime.TotalSeconds
                    });
                }
            }
            else if (Client.IsInGame && !Client.Game.Ended && !_ui.IsOnEmpty())
            {
                _ui.UnwindAndEmpty();
            }
            else if (Client.IsInGame)
            {
                ActivateGameInput();

                //Handle spectating
                if (!_spectateHasSwitchedTank && CurrentViewedTank != null && !CurrentViewedTank.Alive)
                {
                    Client.Game.TimerFactory.CreateTimer((t) =>
                    {
                        SpectateRandomTank();
                        _spectateHasSwitchedTank = false;
                    },
                                                         TimeSpan.FromSeconds(3));
                    _spectateHasSwitchedTank = true;
                }
                if (Client.Game.Ended)
                {
                    _ui.GoToPageIfNotThere("gameendedpage", page => { }, (page, state) =>
                    {
                        var winningTeam = Client.Game.Gamemode.WinningTeam;
                        bool winner     = (Client.Player?.Tank.Team == winningTeam);

                        page.Element <TextBlock>("Header").Text = winner ? "You're Winner" : "You Tried";
                        if (winningTeam == Engine.Gamemodes.Team.Indeterminate)
                        {
                            page.Element <TextBlock>("Subscript").Text = "It's a draw";
                        }
                        else if (winningTeam == Engine.Gamemodes.Team.Null)
                        {
                            page.Element <TextBlock>("Subscript").Text = "This gamemode has a bug..."; //Wow, so much faith in the game's implementation
                        }
                        else
                        {
                            page.Element <TextBlock>("Subscript").Text = winningTeam.TeamName + " won";
                        }

                        page.Element <Image>("Star").Visibility =
                            winner ? EmptyKeys.UserInterface.Visibility.Collapsed :
                            EmptyKeys.UserInterface.Visibility.Visible;

                        if (winningTeam?.Players != null)
                        {
                            page.Element <TextBlock>("PlayerList").Text = string.Join("\n", winningTeam.Players.Select(a => a.Username));
                        }
                    }, new { });
                    _ui.UpdateState(new object());
                }
            }
            else
            {
                DeactivateGameInput();
                if (!_ui.IsOnPage("settingupprompt"))
                {
                    ShowSetupPrompt();
                }
                switch (Client.Status)
                {
                case NetClient.ClientStatus.Authenticating:
                    _ui.UpdateState(new
                    {
                        Header  = "Logging in...",
                        Content = "Authenticating with the ZSB servers",
                        Button  = "Cancel"
                    });
                    break;

                case NetClient.ClientStatus.Connected:
                    _ui.UpdateState(new
                    {
                        Header  = "Connected...",
                        Content = "Waiting for the server to respond",
                        Button  = "Leave server"
                    });
                    break;

                case NetClient.ClientStatus.Connecting:
                    _ui.UpdateState(new
                    {
                        Header  = "Connecting to the server...",
                        Content = Client.Message,
                        Button  = "Abort"
                    });
                    break;

                case NetClient.ClientStatus.Disconnected:
                    _closing = true;
                    _ui.ShowMessageBox("Disconnected", Client.Message, UserInterface.MessageBoxType.ErrorMessageBox,
                                       UserInterface.MessageBoxButtons.Ok, a => Exit());
                    break;

                case NetClient.ClientStatus.DownloadingMods:
                    _ui.UpdateState(new
                    {
                        Header  = "Downloading mods...",
                        Content = "This may take a a while",
                        Button  = "Leave server"
                    });
                    break;

                case NetClient.ClientStatus.Errored:
                    _ui.UpdateState(new
                    {
                        Header  = "A fatal error has occured",
                        Content = "",
                        Button  = "Set my hair on fire and leave"
                    });
                    break;

                case NetClient.ClientStatus.NotStarted:
                    _ui.UpdateState(new
                    {
                        Header  = "Waiting to connect...",
                        Content = "This shouldn't usually happen",
                        Button  = "Stare with contempt"
                    });
                    break;
                }
            }

            if (GameSettings.Instance.ForceFullGCEveryFrame)
            {
                GC.Collect(2, GCCollectionMode.Forced, true);
            }
        }
Exemple #23
0
 private void ActivateGameInput()
 {
     InputDriver?.Activate();
     IsMouseVisible = false;
 }
Exemple #24
0
 private void DeactivateGameInput()
 {
     InputDriver?.Deactivate();
     IsMouseVisible = true;
 }
 private void CatchDriverData(Driver Driver)
 {
     Driver.FirstName = InputDriver.CatchDriverFirstName();
     Driver.LastName  = InputDriver.CatchDriverLastName();
 }
Exemple #26
0
 void Awake()
 {
     instance = this;
 }
 /// <summary>
 /// Initializes a <see cref="ControllerElementMappingProfile"/> from an <see cref="IDeviceLayoutMapping"/>,
 /// that includes all mappings from the default layout.
 /// </summary>
 /// <param name="deviceName">The name of the physical device for this set of mappings.</param>
 /// <param name="controllerId">The Stone <see cref="ControllerID"/> this mapping is intended for.</param>
 /// <param name="driver">The <see cref="InputDriver"/> of the device instance for this set of mappings.</param>
 /// <param name="vendor">The vendor ID of the physical device for this set of mappings.</param>
 /// <param name="mapping">The device layout mapping provided by the device enumerator.</param>
 /// <param name="profileGuid">The <see cref="Guid"/> of this mapping profile.</param>
 public ControllerElementMappingProfile(string deviceName,
                                        ControllerId controllerId, InputDriver driver, int vendor,
                                        IDeviceLayoutMapping mapping)
     : this(deviceName, controllerId, driver, vendor, mapping, Guid.NewGuid())
 {
 }
Exemple #28
0
 void Start()
 {
     prevSpeed = speed;
     cameraRotation.send_speed(speed);
     inputDriver = FindObjectOfType<InputDriver>();
 }
Exemple #29
0
 public Wheel(InputDriver driver)
 {
     driver.Update += Driver_Update;
 }
Exemple #30
0
 void Start()
 {
     snake = FindObjectOfType<SnakeController>();
     speedLocker = FindObjectOfType<RotateForward>();
     inputDriver = FindObjectOfType<InputDriver>();
 }
Exemple #31
0
 /// <summary>
 /// Instantiate an input mapping with the given dictionary of mappings.
 /// </summary>
 /// <param name="elementMappings">The dictionary of mappings from <see cref="DeviceCapability"/> to input configuration string.</param>
 public DictionaryInputMapping(InputDriver driver, IDictionary <DeviceCapability, string> elementMappings)
 {
     this.Driver          = driver;
     this.elementMappings = elementMappings;
 }
Exemple #32
0
        public IEnumerable <(string profileName, Guid profileGuid)> GetProfileNames(ControllerId controllerId, InputDriver driverType, string deviceName, int vendorId)
        {
            using var context = new DatabaseContext(this.Options.Options);
            var retrievedMappings = context.ControllerElementMappings
                                    .Where(p => p.ControllerID == controllerId &&
                                           p.DriverType == driverType &&
                                           p.DeviceName == deviceName &&
                                           p.VendorID == vendorId)
                                    .ToList()
                                    .Select(p => (p.ProfileName, p.ProfileID));

            return(retrievedMappings);
        }
 public void SetPort(IEmulatorOrchestrator orchestrator, PlatformId platform, int portNumber,
                     ControllerId controller, Guid deviceInstanceGuid, InputDriver instanceDriver, Guid inputProfile)
 => this.SetPort(platform, portNumber, controller, deviceInstanceGuid, instanceDriver, inputProfile, orchestrator.Name);
Exemple #34
0
 void Start()
 {
     inputDriver = FindObjectOfType<InputDriver>();
 }