
    _c                         S SK r S SKJr  S SKJrJr  S SKJrJrJ	r	J
r
  S SKJr  SSKJr  \ " S S	5      5       r " S
 S\5      r " S S\5      r " S S\5      rg)    N)	dataclass)Enumauto)ListOptionalSequenceTuple)DeprecationHelper   )GFxMoviec                   2    \ rS rSr% Sr\\S'   Sr\\S'   Srg)OptionBoxButton   z
A simple dataclass representing a button for `OptionBox`s.

Attributes:
    Name: The name that the button should have.
    Tip: A string that is added to the option box caption when hovering over this button.
Name Tip N)	__name__
__module____qualname____firstlineno____doc__str__annotations__r   __static_attributes__r       aZ:\mnt\Skyabridged\SteamLibrary\steamapps\common\Borderlands 2\sdk_mods\UserFeedback\OptionBox.pyr   r      s     ICMr   r   c                   l    \ rS rSrSr\" 5       r\" 5       r\" 5       r\" 5       r	\" 5       r
\" 5       rSrg)OptionScrollType   a  
An enum for the various ways an `OptionBox` can scroll between pages.

                             | Direction | Infinite  | Activator |  Display
-----------------------------+-----------+-----------+-----------+-----------
UNIDIRECTIONAL               |    Uni    |    Yes    |   Click   |   4/4/4
BIDIRECTIONAL                |    Bi     |    No     |   Click   |   4/3/4
BIDIRECTIONAL_INFINITE       |    Bi     |    Yes    |   Click   |   3/3/3
UNIDIRECTIONAL_HOVER         |    Uni    |    Yes    |   Hover   |   4/4/4
BIDIRECTIONAL_HOVER          |    Bi     |    No     |   Hover   |   4/3/4
BIDIRECTIONAL_INFINITE_HOVER |    Bi     |    Yes    |   Hover   |   3/3/3

Direction:  Which directions you can scroll.
Infinite:   If you can scroll from the last page back to first.
Activator:  What activates scrolling - clicking on the button or hovering over it.
Display:    How many buttons are displayed on the first/midde/last page(s). The last page may
             have less of course, and if there's only one page it may have up to 5.
r   N)r   r   r   r   r   r   UNIDIRECTIONALBIDIRECTIONALBIDIRECTIONAL_INFINITEUNIDIRECTIONAL_HOVERBIDIRECTIONAL_HOVERBIDIRECTIONAL_INFINITE_HOVERr   r   r   r   r   r      s7    $ VNFM!V6&#'6 r   r   c                      \ rS rSr% Sr\\S'   \\S'   \\S'   \\   \S'   \	\S'   \
\S'   \	\S	'   \\R                     \S
'   SSSSSS.S\S\S\S\\   S\	S\
S	\	SS4S jjrSS jrS\
4S jrSS jrS\4S jrS\SS4S jrSS jrSrg)_Page3   a  
Class representing a single 'page' option box. You should probably use OptionBox over this.

This class behaves very similarly to OptionBox. The main differences are that it's limited to no
 more than 5 buttons (and thus doesn't have scrolling logic), you don't need to call Update()
 when you change attributes, and that it uses a DefaultButtonIndex field rather than having a
 special show method.

You should only really use this class if you want to create your own logic for multiple pages.
TitleCaptionTooltipButtonsDefaultButtonIndexPreventCancelingPriority
_OptionBoxr   zI<StringAliasMap:GFx_Accept> Select     <StringAliasMap:GFx_Cancel> Cancelr   F   )r+   r,   r.   r/   r0   returnNc                R    U H  n[        U[        5      (       a  M  [        e   [        U5      S:  d  [        U5      S:  a  [        S5      e[        U5      S:  d  [        U5      [        U5      :  a  [        S5      e[        U5      U l
        [        U5      U l        [        U5      U l        X@l        [        U5      U l        [        U5      U l        [        U5      U l        S U l        g ! [         a-  n	[        SU S35      R	                  U	R
                  5      eS n	A	ff = f)N'' is not a sequence of Buttonsr      z)A single option box must have 1-5 buttonsr   z!Default button index out of range)
isinstancer   	TypeError
ValueErrorwith_traceback__traceback__lenint
IndexErrorr   r*   r+   r,   r-   r.   boolr/   r0   r1   )
selfr*   r+   r,   r-   r.   r/   r0   bes
             r   __init___Page.__init__H   s   	.!!_55#O  w<!s7|a/HII!"Q&#.@*AS\*Q@AAZ
7|7|"%&8"9 $%5 6H#  	.G9:;nQ__-.	.s   C/ C/ /
D&9(D!!D&c                 2  ^  [         R                  " 5       R                  S   R                  R                  R                  5       T l        T R                  R                  T R                  T R                  5        T R                  T R                  l        T R                  R                  T R                  5        T R                  R                  T R                  5        [!        [#        T R$                  5      5       HQ  nT R                  R'                  SU 3T R$                  U   R(                  T R$                  U   R*                  5        MS     T R                  R-                  ST R.                   3S5        T R                  R1                  5         S[         R2                  S[         R4                  S[         R6                  S[8        4U 4S jjnS[         R2                  S[         R4                  S[         R6                  S[8        4U 4S	 jjnS[         R2                  S[         R4                  S[         R6                  S[8        4U 4S
 jjn[         R:                  " SSU5        [         R:                  " SSU5        [         R:                  " SSU5        g )Nr   ButtonTcallerfunctionparamsr3   c                    > U TR                   :X  a}  [        R                  " SS5        [        R                  " SS5        [        R                  " SS5        S Tl         TR                  TR                  [        U R                  5         5        gN&WillowGame.WillowGFxDialogBox.AcceptedCustomOptionBox'WillowGame.WillowGFxDialogBox.Cancelled,WillowGame.WillowGFxDialogBox.HandleInputKeyT)r1   	unrealsdk
RemoveHookOnPressr-   r>   CurrentSelectionrH   rI   rJ   rA   s      r   Accepted_Page.Show.<locals>.Accepted{   so    ($$%MO`a$$%NPab$$%SUfg"&T\\#f.E.E*FGHr   c                    > U TR                   :X  a\  [        R                  " SS5        [        R                  " SS5        [        R                  " SS5        S Tl         TR                  5         grL   )r1   rQ   rR   OnCancelrU   s      r   	Cancelled_Page.Show.<locals>.Cancelled   sX    ($$%MO`a$$%NPab$$%SUfg"&r   c                 r   > U TR                   :X  a&  TR                  UR                  UR                  5        g)NT)r1   OnInputukeyueventrU   s      r   HandleInputKey"_Page.Show.<locals>.HandleInputKey   s(    (V[[&--8r   rM   rN   rO   rP   )rQ   	GetEngineGamePlayersActorGFxUIManager
ShowDialogr1   SetTextr*   r+   r/   	bNoCancelSetTooltipsr,   SetPriorityr0   ranger=   r-   AppendButtonr   r   SetDefaultButtonr.   ApplyLayoutUObject	UFunctionFStructr@   RegisterHook)rA   idxrV   rZ   r`   s   `    r   Show
_Page.Showj   s   #--/;;A>DDQQ\\^

DLL9$($9$9!##DLL1##DMM2 T\\*+COO((6#c9J9O9OQUQ]Q]^aQbQfQfg , 	((6$2I2I1J)KTR##%	Y.. 	):M:M 	W`WhWh 	mq 		i// 	9;N;N 	XaXiXi 	nr 		9#4#4 		@S@S 	]f]n]n 	sw 	
 	GIZ\deHJ[]fgMO`bpqr   c                     U R                   S L$ N)r1   rA   s    r   	IsShowing_Page.IsShowing   s    d**r   c                 N   [         R                  " SS5        [         R                  " SS5        [         R                  " SS5        U R                  c  [         R                  " S5        g U R                  R	                  S5        U R                  R                  5         S U l        g )NrM   rN   rO   rP   zO[UserFeedback] Warning: tried to hide a option box page that was already closedr   )rQ   rR   r1   LogrZ   Closerx   s    r   Hide
_Page.Hide   s    EGXYFHYZKM^_ ??"MMa  	!!!$r   c                     U R                   c  [        S5      eU R                  [        U R                   R                  5         $ )NzKTried to get selected button of an option box that is not currently showing)r1   RuntimeErrorr-   r>   rT   rx   s    r   GetSelectedButton_Page.GetSelectedButton   s<    ??"]  ||C @ @ABBr   buttonc                     g rw   r   rA   r   s     r   rS   _Page.OnPress       r   c                     g rw   r   rx   s    r   rY   _Page.OnCancel   r   r   )r-   r+   r.   r/   r0   r*   r,   r1   r3   N)r   r   r   r   r   r   r   r   r   r>   r@   r   rQ   ro   rD   rt   ry   r~   r   rS   rY   r   r   r   r   r(   r(   3   s    	 JLLo&&M**++
 b"#!&     	 
 /*         
 D*rX+4 +&C? Co $ r   r(   c                      \ rS rSr% Sr\S5S\S\S\4S jj5       r\\S'   \\S'   \\S	'   \	\
   \S
'   \\S'   \\S'   \\S'   SSSS\R                  S.S\S\S	\S
\	\
   S\S\S\SS4S jjr\\   \S'   \\S'   \
\S'   \
\S'   Sr\\S4   \S'   Sr\\S4   \S'   S6S jrS7S\\
   SS4S  jjrS\4S! jrS6S" jrS\
4S# jrS$\S%\SS4S& jrS6S' jrS\
SS4S( jrS6S) jr \R@                  " \RB                  " S*S+5      5      S\
SS4S, j5       r" S6S- jr#S6S. jr$S6S/ jr%S6S0 jr&S\
SS4S1 jr'S$\S%\SS4S2 jr(S6S3 jr)S4r*g)8	OptionBox   a>  
Class representing an option box with multiple options to chose from, like those used to select
 playthrough or confirm quitting.

If you provide more buttons than a single box can handle it will automatically create multiple
 pages with a button to cycle between them.

See https://i.imgur.com/E5TOicS.png for examples of what the various sections of the option box
 are called.

Attributes:
    Title: The title text to display at the top of the option box.
    Caption: The text to display in the main body of the option box.
    Tooltip: The text to display in the footer of the option box.
    Buttons: A sequence of buttons that the user should pick from. This may contain duplicates.
    PreventCanceling:
        If the user should be prevented from pressing ESC to cancel out of the option
         without selecting anything.
    Priority:
        A byte representing the priority of the option box in reference to the game's other
         `GfxMovie`s. Higher values display above lower ones.
    ScrollType: How the option box scrolls between pages, if there are multiple.
EnterMessage
EscMessager3   c                     SU  SU 3$ )ai  
Creates a tooltip string in the same format the game uses, but with custom messages.

Args:
    EnterMessage: The message to display after the enter prompt. Defaults to "Select".
    EscMessage: The message to display after the escape prompt. Defaults to "Cancel".
Returns:
    A string in the same format as the game's tooltips, but with your custom prompts.
z<StringAliasMap:GFx_Accept> z!     <StringAliasMap:GFx_Cancel> r   )r   r   s     r   CreateTooltipStringOptionBox.CreateTooltipString   s     +<.++5,8	
r   r*   r+   r,   r-   r/   r0   
ScrollTyper   zH<StringAliasMap:GFx_Accept> Select    <StringAliasMap:GFx_Cancel> CancelFr2   )r+   r,   r/   r0   r   Nc                    Xl         X l        X0l        X@l        XPl        X`l        Xpl        SU l        [        S5      U l	        [        S5      U l
        U R                  5         g)al  
Creates an Option Box.

Args:
    Title: The title text to display at the top of the option box.
    Caption:
        The text to display in the main body of the option box. Defaults to the empty
         string.
    Tooltip:
        The text to display in the footer of the option box. Defaults to the game's default
         tooltip, which explains the keybinds.
    Buttons:
        A sequence of OptionBoxButtons that the user should pick from. These will
         automatically be split into pages. This may contain duplicates.
    PreventCanceling:
        If the user should be prevented from pressing ESC to cancel out of the option
         without selecting anything. Defaults to false.
    Priority:
        A byte representing the priority of the option box in reference to the game's other
         `GfxMovie`s. Higher values display above lower ones. Defaults to 254, the same as
         the game's default.
Raises:
    TypeError: If not passed a sequence of `OptionBoxButton`s.
    ValueError:
        If not passed at least one button.
        If ScrollType has an invalid value not equal to anything in the enum.
r   z	Next PagezPrevious PageN)r*   r+   r,   r-   r/   r0   r   _CurrentPageIndexr   _NextPageButton_PreviousPageButtonUpdate)rA   r*   r+   r,   r-   r/   r0   r   s           r   rD   OptionBox.__init__   sT    J 
 0 $!".{;#2?#C r   _Pagesr   r   r   )UpXboxTypeS_DPad_UpGamepad_LeftStick_Up._UP_KEYS)DownXboxTypeS_DPad_DownGamepad_LeftStick_Down
_DOWN_KEYSc                 j    U R                    H  n[        U[        5      (       a  M  [        e   [        U R                   5      S:  a  [	        S5      e/ U l        / n[        U R                   5      S::  a&  UR                  [        U R                   5      5        GOU R                  [        R                  [        R                  4;   aW  [        S[        U R                   5      S5       H1  nUR                  / U R                   XDS-    QU R                   P5        M3     GOU R                  [        R"                  [        R$                  4;   a  UR                  / U R                   SS QU R                   P5        [        S[        U R                   5      S	5       H<  nUR                  U R&                  /U R                   XDS	-    QU R                   P5        M>     US
   R)                  5         [        US
   5      S:X  a  US
   S   US   S
'   US
	 OU R                  [        R*                  [        R,                  4;   aa  [        S[        U R                   5      S	5       H<  nUR                  U R&                  /U R                   XDS	-    QU R                   P5        M>     O[	        S5      eU H  n[/        [1        U R2                  5      [1        U R4                  5      [1        U R6                  5      U[9        U R:                  5      [=        U R>                  5      S9nU R@                  Ul!        U RD                  Ul#        U RH                  Ul%        U R                  R                  U5        M     g! [         a7  n[	        SU R                    S35      R                  UR                  5      eSnAff = f)aL  
Updates all of the internal pages to use the values currently stored in the attributes.

Must be called whenever you update the attributes, otherwise the displayed boxes will
 continue to use the old values.

Buttons are somewhat an exception to this - you may change their attributes without calling
 this, but you must call it if you change the button list.

Raises:
    TypeError: If not passed a sequence of `OptionBoxButton`s.
    ValueError:
        If Buttons is not a sequence of at least one button.
        If ScrollType has an invalid value not equal to anything in the enum.
r5   r6   Nr   z+An option box must have at least one buttonr7   r            zInvalid scroll type)r*   r+   r,   r-   r/   r0   )&r-   r8   r   r9   r:   r;   r<   r=   r   appendlistr   r   r!   r$   rk   r   r"   r%   r   popr#   r&   r(   r   r*   r+   r,   r@   r/   r>   r0   _InternalOnPressrS   _InternalOnInputr]   _InternalOnCancelrY   )rA   rB   rC   button_groupsigroupboxs          r   r   OptionBox.Update+  s   $	.\\!!_55#O " t||q JKK57t||!  dll!34__!1!@!@BRBgBg hh1c$,,/3$$%St||A!e'<%Sd>R>R%ST 4 __!1!?!?AQAeAe ff  !K4<<!#4!Kd6J6J!KL1c$,,/3$$--\Q1u0E\tG[G[\ 4 "!!#=$%*(5b(9!(<b!"%!"%__!1!H!HJZJwJw xx1c$,,/3$$--\Q1u0E\tG[G[\ 4
 233"E$**oDLL)DLL)!%d&;&;!<T]]+C //CK//CK11CLKKs## #M  	.DLL>!?@nQ__-.	.s   "M1 M1 1
N2;2N--N2r   c                    U R                   U R                     nUcZ  SUl        U R                  [        R
                  [        R                  4;   a$  UR                  S   U R                  :X  a  SUl        OXR                  ;   a!  UR                  R                  U5      Ul        OsU R                    HT  nXR                  ;   d  M  U R                   R                  U5      U l        UR                  R                  U5      Ul          O   [        SU S35      eU R                   U R                     R                  5         g)a  
Displays the option box on the current page.

If the user scrolls through a few pages before exiting the option box then calling this
 function again will re-show the page they exited on.

By default selects the first button, but optionally can select a specific button. If the
 same button has been included in the list multiple times, it will prioritize the first copy
 on the current page, followed by the first copy in the overall list.

Args:
    button: An optional arg specifying the button that should be selected. Defaults to None.
Raises:
    ValueError:
        If the provided button is not currently in one of the stored pages. This may happen
         if you forgot to call Update().
Nr   r   zProvided button z$ is not on any of the current pages!)r   r   r.   r   r   r%   r&   r-   r   indexr:   rt   )rA   r   current_pagepages       r   rt   OptionBox.Showz  s   & {{4#9#9:>./L+ 44 ==#  &&q)T-E-EE23/+++.:.B.B.H.H.PL+\\)-1[[->->t-DD*.2ll.@.@.HD+	 $ !#3F8;_!`aaD**+002r   c                 P    U R                   U R                     R                  5       $ )z
Gets if the option box is currently being displayed.

Returns:
    True if the option is currently being displayed, False otherwise.
)r   r   ry   rx   s    r   ry   OptionBox.IsShowing  s"     {{4112<<>>r   c                 R    U R                   U R                     R                  5         g)z
Hides the option box, without running any of the callbacks.

Displays a warning but does nothing if the option box is not currently being displayed.
N)r   r   r~   rx   s    r   r~   OptionBox.Hide  s     	D**+002r   c                 P    U R                   U R                     R                  5       $ )z
Gets the button the user has current got selected.

Returns:
    The button the user has currently got selected
Raises:
    RuntimeError: If the option box is not currently showing
)r   r   r   rx   s    r   r   OptionBox.GetSelectedButton  s"     {{4112DDFFr   keyeventc                     g)a  
Callback function called any time the user inputs anything while the option box is open.

Args:
    key:
        The key that was pressed. See the following link for reference.
        https://api.unrealengine.com/udk/Three/KeyBinds.html#Mappable%20keys
    event:
        The input event type. See the following link for reference.
        https://docs.unrealengine.com/en-US/API/Runtime/Engine/Engine/EInputEvent/index.html
Nr   )rA   r   r   s      r   r]   OptionBox.OnInput  s     	r   c                     g)z6Callback function called when the user changes pages. Nr   rx   s    r   OnPageChangeOptionBox.OnPageChange      r   c                     g)zo
Callback function called when the user presses a button.

Args:
    button: The button that the user pressed.
Nr   r   s     r   rS   OptionBox.OnPress  s     	r   c                     g)zFCallback function called when the user cancels out of the option box. Nr   rx   s    r   rY   OptionBox.OnCancel  r   r   zOptionBox.ShowButton()zOptionBox.Show(button)c                 &    U R                  U5        g)ak  
This has been deprecated since version 1.3. Use the optional argument on `Show()` instead.

Displays the option box with the provided button selected.

Args:
    button: The button you want to be selected
Raises:
    ValueError:
        If the provided button is not currently in one of the stored pages. This may happen
         if you forgot to call Update().
N)rt   r   s     r   
ShowButtonOptionBox.ShowButton  s     			&r   c                    U R                   S-
  [        U R                  5      -  nSn[        U R                  5      S:X  a  SnU R                  [        R
                  :X  a  SnO]U R                  [        R                  :X  a  U[        U R                  5      S-
  :w  a  SnO U R                  [        R                  :X  a  SnU R                  5       (       a  U R                  5         Xl         U R                  U R                  U   R                  U   5        [        U R                  5      S:  a  U R                  5         g g )Nr   r   r   r   )r   r=   r   r   r   r$   r%   r&   ry   r~   rt   r-   r   rA   page_idx
button_idxs      r   _PageUpOptionBox._PageUp  s    **Q.#dkk2BB
t{{q J??.CCCJ__ 0 D DD3t{{+a//
__ 0 M MMJ>>IIK!)		$++h'//
;<t{{a  r   c                    U R                   S-   [        U R                  5      -  nSn[        U R                  5      S:X  a  SnOGU R                  [        R
                  :X  a	  US:w  a  SnO U R                  [        R                  :X  a  SnU R                  5       (       a  U R                  5         Xl         U R                  U R                  U   R                  U   5        [        U R                  5      S:  a  U R                  5         g g )Nr   r   r   )r   r=   r   r   r   r%   r&   ry   r~   rt   r-   r   r   s      r   	_PageDownOptionBox._PageDown  s    **Q.#dkk2BB
t{{q J__ 0 D DD1}
__ 0 M MMJ>>IIK!)		$++h'//
;<t{{a  r   c                 4   U R                  5         SnU R                  [        R                  :X  a  U R                  S:w  a  SnO U R                  [        R
                  :X  a  SnU R                  U R                  U R                     R                  U   5        g )Nr   r   )	r~   r   r   r%   r   r&   rt   r   r-   rA   r   s     r   _HomeOptionBox._Home  su    		
??.BBB%%*
__ 0 M MMJ		$++d445==jIJr   c                    U R                  5         SnU R                  [        R                  :X  a  SnOgU R                  [        R                  :X  a)  U R
                  [        U R                  5      S-
  :w  a  SnO U R                  [        R                  :X  a  SnU R                  U R                  U R
                     R                  U   5        g )Nr   r   r   )r~   r   r   r$   r%   r   r=   r   r&   rt   r-   r   s     r   _EndOptionBox._End'  s    		
??.CCCJ__ 0 D DD%%T[[)9A)==
__ 0 M MMJ		$++d445==jIJr   c                     XR                   :X  a  U R                  5         g XR                  :X  a  U R                  5         g U R	                  U5        g rw   )r   r   r   r   rS   r   s     r   r   OptionBox._InternalOnPress5  s9    )))NN///LLNLL r   c                    US:X  Ga6  US:X  at  U R                   S:X  aR  U R                  [        R                  [        R                  4;   a  U R                  5         GOU R                  5         GOU R                  5         GOyUS:X  a  U R                   [        U R                  5      S-
  :X  aQ  U R                  [        R                  [        R                  4;   a  U R                  5         GOU R                  5         OU R                  5         OUS:X  a  U R                  5         OUS:X  a  U R                  5         OUS:X  a  U R                  [        R                  [        R                  [        R                  4;   nU R                  5       nXR                  ;   a'  U(       a   X@R                  :X  a  U R                  5         O5XR                   ;   a&  U(       a  X@R"                  :X  a  U R                  5         U R%                  X5        g )Nr   PageUpPageDownr   HomeEnd)r   r   r   r"   r%   r   r   r=   r   r   r   r$   r&   r   r   r   r   r   r]   )rA   r   r   is_hover_scrollselected_buttons        r   r   OptionBox._InternalOnInput=  sk   A:h))Q.+;+I+IK[KoKo*pp

LLN
"))S-=-AA+;+I+IK[KoKo*pp		(NN$

		aZ"oo 55 44 ==2 O
 #446Omm#OOgOg<g'OSgSg@g S r   c                 $    U R                  5         g rw   )rY   rx   s    r   r   OptionBox._InternalOnCancela  s    r   )r-   r+   r/   r0   r   r*   r,   r   r   r   r   )SelectCancelr   rw   )+r   r   r   r   r   staticmethodr   r   r   r   r   r@   r>   r   r$   rD   r   r(   r   r	   r   r   r   rt   ry   r~   r   r]   r   rS   rY   dh
DeprecatedNameChangeMsgr   r   r   r   r   r   r   r   r   r   r   r   r   r      s   0 
# 
c 
Y\ 
 
  JLLo&&M  
 a!&'7'L'L11 1 	1
 /*1 1 1 %1 
1f K$$((!HeCHo #Jc3h M$^'38O4 '3 '3R?4 ?3	G? 	G3 s t o $  *]]2##$<>VWX T  Y  * &
KK! !4 !"!C "! "! "!Hr   r   )rQ   dataclassesr   enumr   r   typingr   r   r   r	   Mods.ModMenur
   r   r   r   r   r(   r   r   r   r   <module>r      s\     !  2 2 0  	 	 	*t *6DH DNh hr   