Example #1
0
 private void InitializeSettings()
 {
     sequence = new HotkeySequence(Settings.Hotkey);
     if (!String.IsNullOrEmpty(Settings.Hotkey) && !sequence.IsValidSequence)
     {
         Settings.Hotkey = "INVALID - TRY AGAIN";
         SaveSettings();
     }
 }
        public override void Update()
        {
            base.Update();

            // Display nothing and exit if quest debugger not enabled
            if (!DaggerfallUnity.Settings.EnableQuestDebugger)
            {
                displayState = DisplayState.Nothing;
                return;
            }

            // Do not tick while HUD fading or load in progress
            // This is to prevent quest popups or other actions while player/world unavailable
            if (DaggerfallUI.Instance.FadeBehaviour.FadeInProgress || SaveLoadManager.Instance.LoadInProgress)
            {
                return;
            }

            if (QuestMachine.Instance.QuestCount == 0 && currentQuest != null)
            {
                ClearCurrentQuest();
                FullRefresh();
                return;
            }

            if (allQuests == null || allQuests.Length != QuestMachine.Instance.QuestCount)
            {
                FullRefresh();
            }

            // Clamp display state
            if (displayState < DisplayState.Nothing || displayState > DisplayState.QuestStateFull)
            {
                displayState = DisplayState.Nothing;
            }

            // Change quest selection
            HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers();
            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerPrevQuest).IsDownWith(keyModifiers))
            {
                MovePreviousQuest();
            }
            else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerNextQuest).IsDownWith(keyModifiers))
            {
                MoveNextQuest();
            }

            // Change marker selection
            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerPrevMarker).IsDownWith(keyModifiers))
            {
                MovePreviousMarker();
            }
            else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerNextMarker).IsDownWith(keyModifiers))
            {
                MoveNextMarker();
            }
        }
        public override void Update()
        {
            base.Update();

            if (lastChunk && !answerGiven)
            {
                HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers();
                if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.Yes).IsUpWith(keyModifiers))
                {
                    HandleAnswer(QuestMachine.QuestMessages.AcceptQuest);
                    QuestMachine.Instance.StartQuest(daedraQuest);
                }
                else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.No).IsUpWith(keyModifiers))
                {
                    HandleAnswer(QuestMachine.QuestMessages.RefuseQuest);
                    GameObjectHelper.CreateFoeSpawner(true, DaggerfallQuestPopupWindow.daedricFoes[UnityEngine.Random.Range(0, 5)], UnityEngine.Random.Range(3, 6), 8, 64);
                }
            }
        }
        public override void Update()
        {
            base.Update();
            Cursor.visible = true;

            HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers();
            // Shortcuts for options
            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.MainMenuLoad).IsUpWith(keyModifiers))
            {
                LoadGame();
            }
            else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.MainMenuStart).IsUpWith(keyModifiers))
            {
                StartNewGame();
            }
            else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.MainMenuExit).IsUpWith(keyModifiers))
            {
                ExitGame();
            }
        }
        public override void Update()
        {
            base.Update();

            HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers();
            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.BookPageRight).IsDownWith(keyModifiers))
            {
                ScrollBook(-scrollAmount);
            }
            else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.BookPageLeft).IsDownWith(keyModifiers))
            {
                ScrollBook(scrollAmount);
            }
            else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.BookLineUp).IsDownWith(keyModifiers))
            {
                ScrollBook(1);
            }
            else if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.BookLineDown).IsDownWith(keyModifiers))
            {
                ScrollBook(-1);
            }
        }
Example #6
0
        private static void CheckLoaded()
        {
            if (keys == null)
            {
                keys = new Dictionary <Buttons, HotkeySequence>();
                foreach (Buttons button in Enum.GetValues(typeof(Buttons)))
                {
                    if (button == Buttons.None)
                    {
                        continue;
                    }

                    string buttonName = Enum.GetName(typeof(Buttons), button);
                    if (TextManager.Instance.HasText(textDatabase, buttonName))
                    {
                        keys[button] = HotkeySequence.FromString(TextManager.Instance.GetText(textDatabase, buttonName));
                    }
                    else
                    {
                        Debug.Log(string.Format("{0}: no {1} entry", textDatabase, buttonName));
                    }
                }
            }
        }
        public override void Update()
        {
            // Update HUD visibility
            popupText.Enabled           = ShowPopupText;
            midScreenTextLabel.Enabled  = ShowMidScreenText;
            crosshair.Enabled           = ShowCrosshair;
            vitals.Enabled              = ShowVitals;
            compass.Enabled             = ShowCompass;
            interactionModeIcon.Enabled = ShowInteractionModeIcon;
            placeMarker.Enabled         = ShowLocalQuestPlaces;
            escortingFaces.EnableBorder = ShowEscortingFaces;
            questDebugger.Enabled       = !(questDebugger.State == HUDQuestDebugger.DisplayState.Nothing);
            activeSpells.Enabled        = ShowActiveSpells;

            // Large HUD will force certain other HUD elements off as they conflict in space or utility
            bool largeHUDEnabled = false;//DaggerfallUnity.Settings.LargeHUD;

            if (largeHUDEnabled)
            {
                largeHUD.Enabled            = true;
                vitals.Enabled              = false;
                compass.Enabled             = false;
                interactionModeIcon.Enabled = false;
            }
            else
            {
                largeHUD.Enabled = false;
            }

            // Scale HUD elements
            largeHUD.Scale            = NativePanel.LocalScale * DaggerfallUnity.Settings.LargeHUDScale;
            compass.Scale             = NativePanel.LocalScale;
            vitals.Scale              = NativePanel.LocalScale;
            crosshair.CrosshairScale  = CrosshairScale;
            interactionModeIcon.Scale = NativePanel.LocalScale;

            // Align compass to screen panel
            Rect  screenRect = ParentPanel.Rectangle;
            float compassX   = screenRect.width - (compass.Size.x);
            float compassY   = screenRect.height - (compass.Size.y);

            compass.Position = new Vector2(compassX, compassY);

            // Update midscreen text timer and remove once complete
            if (midScreenTextTimer != -1)
            {
                midScreenTextTimer += Time.deltaTime;
                if (midScreenTextTimer > midScreenTextDelay)
                {
                    midScreenTextTimer      = -1;
                    midScreenTextLabel.Text = string.Empty;
                }
            }

            // Update arrow count if player holding an unsheathed bow
            // TODO: Find a spot for arrow counter when large HUD enabled (remembering player could be in 320x200 retro mode)
            arrowCountTextLabel.Enabled = false;
            if (!largeHUDEnabled && ShowArrowCount && !GameManager.Instance.WeaponManager.Sheathed)
            {
                EquipSlots          slot = DaggerfallUnity.Settings.BowLeftHandWithSwitching ? EquipSlots.LeftHand : EquipSlots.RightHand;
                DaggerfallUnityItem held = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(slot);
                if (held != null && held.ItemGroup == ItemGroups.Weapons &&
                    (held.TemplateIndex == (int)Weapons.Long_Bow || held.TemplateIndex == (int)Weapons.Short_Bow))
                {
                    // Arrow count label position is offset to left of compass and centred relative to compass height
                    // This is done every frame to handle adaptive resolutions
                    Vector2 arrowLabelPos = compass.Position;
                    arrowLabelPos.x -= arrowCountTextLabel.TextWidth;
                    arrowLabelPos.y += compass.Size.y / 2 - arrowCountTextLabel.TextHeight / 2;

                    DaggerfallUnityItem arrows = GameManager.Instance.PlayerEntity.Items.GetItem(ItemGroups.Weapons, (int)Weapons.Arrow);
                    arrowCountTextLabel.Text      = (arrows != null) ? arrows.stackCount.ToString() : "0";
                    arrowCountTextLabel.TextScale = NativePanel.LocalScale.x;
                    arrowCountTextLabel.Position  = arrowLabelPos;
                    arrowCountTextLabel.Enabled   = true;
                }
            }

            HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers();
            // Cycle quest debugger state
            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerToggle).IsDownWith(keyModifiers))
            {
                questDebugger.NextState();
            }

            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.Pause).IsUpWith(keyModifiers))
            {
                DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenPauseOptionsDialog);
            }

            // Toggle HUD rendering
            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.HUDToggle).IsDownWith(keyModifiers))
            {
                renderHUD = !renderHUD;
            }

            // Toggle Retro Renderer Postprocessing
            if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.ToggleRetroPP).IsDownWith(keyModifiers))
            {
                RetroRenderer.enablePostprocessing = !RetroRenderer.enablePostprocessing;
            }

            flickerController.NextCycle();

            // Don't display persistent HUD elements during initial startup
            // Prevents HUD elements being shown briefly at wrong size/scale at game start
            if (!startupComplete && !GameManager.Instance.IsPlayingGame())
            {
                largeHUD.Enabled  = false;
                vitals.Enabled    = false;
                crosshair.Enabled = false;
                compass.Enabled   = false;
            }
            else
            {
                startupComplete = true;
            }

            base.Update();
        }
Example #8
0
		/// <summary>
		/// Constructor with a delegate.
		/// </summary>
		/// <param name="id">Shortcut id.</param>
		/// <param name="hs">Hotkey sequence associated with this shortcut.</param>
		/// <param name="handler">Event handler for this shortcut.</param>
		public KeyboardShortcut ( Object  id, HotkeySequence  hs, ShortcutEventHandler  handler ) :
				this ( id, hs )
		   {
			p_Handler		=  handler ;
		    }
Example #9
0
		private ShortcutEventHandler	p_Handler	=  null ;			// Shortcut event handler


		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="id">Shortcut id.</param>
		/// <param name="hs">Hotkey sequence associated with this shortcut.</param>
		public KeyboardShortcut ( Object  id, HotkeySequence  hs )
		   {
			p_Id		=  id ;
			p_Sequence	=  hs ;
		    }
            public static bool checkSetModifiers(HotkeySequence.KeyModifiers pressedModifiers, HotkeySequence.KeyModifiers triggeringModifiers)
            {
                if (triggeringModifiers == KeyModifiers.None)
                {
                    if (pressedModifiers == KeyModifiers.None)
                        return true;
                    else
                        return false;
                }

                return ((pressedModifiers & triggeringModifiers) != 0); // if any of the modifiers in triggeringModifiers is pressed return true
            }