Exemple #1
0
    def _setTooltipText(
        self,
        caller: unrealsdk.UObject,
        function: unrealsdk.UFunction,
        params: unrealsdk.FStruct,
    ) -> bool:
        """
        Handles the hotkey tooltips on the inventory screen.
        Appends our custom hotkey to the end of the original text
        so it still can be localized.
        Only changes the text, doesn't affect the hotkeys.
        """

        # only change the text in the backpack panel
        if caller.bInEquippedView is True:
            return True

        # only change the text when the player is a Mechromancer
        playerController: unrealsdk.UObject = caller.ParentMovie.WPCOwner
        if getVaultHunterClassName(playerController) != "Mechromancer":
            return True

        # only change the text if the item is a valid shield
        item: unrealsdk.UObject = caller.GetSelectedThing()
        if self._isValidShield(item) is False:
            return True

        # make sure the shield isn't overlevelled
        if item.CanBeUsedBy(playerController.Pawn) is False:
            return True
        """
        Get the original hotkey text and append our hotkey.
        The hotkey text changes depending if it's already set as DT shield.
        """
        result: str = ""
        if item.GetMark() == 3:
            result = f"{params.TooltipsText}\n[{self._shieldHotkey.Key}] Unset Deathtrap Shield"
        else:
            result = f"{params.TooltipsText}\n[{self._shieldHotkey.Key}] Set Deathtrap Shield"
        """
        Since we only append our changes to the original text, we need
        to pass our new text as a parameter to the original function.
        Don't call it again afterwards or changes would be overwritten.
        """
        caller.SetTooltipText(result)
        return False
Exemple #2
0
    def _extOnTrashFavChanged(self, caller: unrealsdk.UObject,
                              function: unrealsdk.UFunction,
                              params: unrealsdk.FStruct) -> bool:
        """
        Prevents setting the DT shield as trash or favorite.
        """
        item: unrealsdk.UObject = caller.GetSelectedThing()
        oldMark: int = item.GetMark()

        if item is None:
            return True

        if self._isValidShield(item) is True and oldMark == 3:
            item.SetMark(3)
            caller.OwningMovie.PlayUISound("ResultFailure")
            caller.OwningMovie.RefreshInventoryScreen(True)
            return False

        return True
Exemple #3
0
    def _normalInputKey(
        self,
        caller: unrealsdk.UObject,
        function: unrealsdk.UFunction,
        params: unrealsdk.FStruct,
    ) -> bool:
        """
        Handles the hotkey input on the inventory screen.
        Only checks the input, doesn't affect the tooltips.
        """

        # only listen to key presses
        if params.uevent != KeybindManager.InputEvent.Pressed:
            return True

        # wait until the inventory screen's setup is done
        if caller.bInitialSetupFinished is False:
            return True

        # prevents hotkey usages on swapping or comparing
        if caller.SwitchToQueuedInputHandler(params.ukey, params.uevent):
            return True

        # only allow the hotkey in the backpack panel
        if caller.bInEquippedView is True:
            return True

        # only accept hotkey when the player is a Mechromancer
        playerController: unrealsdk.UObject = caller.ParentMovie.WPCOwner
        if getVaultHunterClassName(playerController) != "Mechromancer":
            return True
        """
        If the modded hotkey is pressed, get the selected item, check if it's
        a valid shield and change its mark depending on the previous mark.
        Also change all other shields to default when a new DT shield is chosen.
        """
        if params.ukey == self._shieldHotkey.Key:
            item: unrealsdk.UObject = caller.GetSelectedThing()

            if self._isValidShield(item) is False:
                return True

            # make sure the shield isn't overlevelled
            if item.CanBeUsedBy(playerController.Pawn) is False:
                caller.ParentMovie.PlayUISound("ResultFailure")
                return True

            # save the state so it doesn't switch to the first item again
            caller.BackpackPanel.SaveState()

            if item.GetMark() == 3:
                item.SetMark(1)
                caller.ParentMovie.PlayUISound("UnEquip")
            else:
                item.SetMark(3)
                caller.ParentMovie.PlayUISound("FinishEquip")
                self._resetAllShields(item, playerController.MyWillowPawn)

            # refresh the inventory screen
            caller.ParentMovie.RefreshInventoryScreen(True)

            # restore the old state
            if caller.bInEquippedView is False:
                caller.BackpackPanel.RestoreState()

            # don't call the original function since we handled our hotkey
            return False

        # if it was some other hotkey which passed the checks, call the original function
        return True