
    0e0                        S SK r S SKJrJrJrJrJr  SSKJr  S SKrS SK	r	\R                  R                  \R                  R                  \R                  R                  \5      5      S5      r\	R                  R!                  \5        SSKJrJrJr  \	R                  R+                  \5        S\\   4S jrS	\SS4S
 jr " S S\5      rg)    N)ClassVarDictListOptionalTuple   )GFxMoviectypes)windllcreate_string_buffermemmovereturnc                     S n [         R                  R                  S 5        [         R                  R                  S5      n[         R                  R                  U5      n[         R                  R                  U5      nU(       aH  U(       aA  [        U5      n[        XBU5        UR                  R                  S5      R                  S5      n [         R                  R                  U5        [         R                  R                  5         U $ )N   utf-16le )r   user32OpenClipboardGetClipboardDatakernel32
GlobalLock
GlobalSizer   r   rawdecoderstripGlobalUnlockCloseClipboard)contentshandle	pcontentssizeraw_datas        dZ:\mnt\Skyabridged\SteamLibrary\steamapps\common\Borderlands 2\sdk_mods\UserFeedback\TextInputBox.py_get_clipboardr$      s    "H
MM%]]++B/F**62I??%%f-DT'-T*<<&&z299%@
OO  (
MM  "O    r   c                    U R                  S5      n[        R                  R                  S 5        [        R                  R	                  5         [        R
                  R                  S[        U5      S-   5      n[        R
                  R                  U5      n[        X1[        U5      5        [        R
                  R                  U5        [        R                  R                  SU5        [        R                  R                  5         g )Nr   B      r   )encoder   r   r   EmptyClipboardr   GlobalAlloclenr   r   r   SetClipboardDatar   )r   datar   r    s       r#   _set_clipboardr/      s    ??:&D
MM%
MM  "__((TQ?F**62IISY'
OO  (
MM""2v.
MM  "r%   c                   X   \ rS rSr% Sr\\S'   \\S'   \\S'   \\S'   \	\   \S'   \\S'   \\S	'   \
\R                     \S
'   Sr\\\S4      \S'   Sr\\\S4      \S'   0 SS_SS_SS_SS_SS_SS_SS_SS_S S!_S"S#_S$S%_S&S'_S(S)_S*S+_S,S-_S.S/_S0S1_0 S2S3_S4S5_S6S7_S8S9_S:S;_S<S=_S>S?_S@SA_SBSC_SDSE_SFSG_SHSI_SJSK_SLSM_SNSO_SPSQ_SRSS_ESTSUSVSWSX.Er\\\\\\4   4      \SY'      SjS\S\S\S\SZS[4
S\ jjrSkS] jrSZ\4S^ jrSkS_ jrS`\SZS[4Sa jrSb\Sc\Sd\SZ\4Se jrSf\Sg\SZS[4Sh jrSirg[)lTextInputBox*   a  
Class representing a custom dialog box that can be used to get text input. Based on the same
 UI element as `TrainingBox`, with heavy modification.

Made for a standard US/Qwerty layout - non-ascii characters may not be recognised, and layouts
 that rearrange the shift symbols may find incorrect values being written.

Attributes:
    Title: The title text to display at the top of the text input box.
    DefaultMessage: The default message that should be displayed when the box is first shown.
    PausesGame: If the text input box should pause the game while it is displayed.
    Priority:
        A byte representing the priority of the text input box in reference to the game's other
         `GfxMovie`s. Higher values display above lower ones.
TitleDefaultMessage
PausesGamePriority_Message
_CursorPos_IsShiftPressed_TrainingBox)EnterLeftMouseButtonXboxTypeS_AXboxTypeS_Start._SubmitKeys)EscapeXboxTypeS_B	_ExitKeysAdd)+rD   Subtract)-rF   Multiply)*rH   Divide)/rJ   One)1!Two)2@Three)3#Four)4$Five)5%Six)6^Seven)7z&amp;Eight)8rH   Nine)9(Zero)0)	NumPadOne)rL   rL   	NumPadTwo)rO   rO   NumPadThree)rR   rR   
NumPadFour)rU   rU   
NumPadFive)rX   rX   	NumPadSix)r[   r[   NumPadSeven)r^   r^   NumPadEight)r`   r`   
NumPadNine)rb   rb   
NumPadZero)re   re   	Backslash)\|Comma),z&lt;Decimal).rw   Equals)=rD   LeftBracket)[{Period)rw   z&gt;Quote)'"RightBracket)]}	Semicolon);:Slash)rJ   ?) r   )	r   )`~)rF   _)SpaceBarTabTilde
Underscore_KeyMapr   Nc                     Xl         X l        X0l        X@l        [	        U5      U l        SU l        SU l        SU l        SU l	        g)aJ  
Creates a text input box.

Args:
    Title: The title text to display at the top of the text input box.
    DefaultMessage:
        The default message that should be displayed when the box is first shown. Defaults
         to the empty string.
    PausesGame:
        If the text input box should pause the game while it is displayed. Defaults to False.
    Priority:
        A byte representing the priority of the text input 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.
r   FN)
r3   r4   r5   r6   listr7   r8   r9   _IsControlPressedr:   )selfr3   r4   r5   r6   s        r#   __init__TextInputBox.__init__{   sD    , 
,$ ^,$!& r%   c                   ^  [        T R                  5      T l        [        T R                  5      T l        ST l        ST l        [        R                  " 5       R                  S   R                  R                  R                  T R                  S-   T R                  SST R                  (       + 5      T l        T R                  R!                  T R"                  5        T R                  R%                  5         S[        R&                  S[        R(                  S[        R*                  S[,        4U 4S jjn[        R.                  " S	S
U5        g)zDisplays the text input box. Fr   z	<u>  </u>callerfunctionparamsr   c                   > U TR                   :w  a  gTR                  UR                  UR                  5        TR	                  UR                  UR                  5        UR                  S:X  a  UR                  TR
                  ;   aI  [        R                  " SS5        S Tl         TR                  SR                  TR                  5      5        OIUR                  TR                  ;   a/  [        R                  " SS5        S Tl         TR                  S5        SnU R                  5       R                  b*  U R                  5       R                  R                  SS5      n[        UR                  5      U:g  $ )NTr   4WillowGame.WillowGFxTrainingDialogBox.HandleInputKeyCustomTextInputBox FAKEUse)r:   _HandleInputukeyueventOnInputr?   	unrealsdk
RemoveHookOnSubmitjoinr7   rB   GetPCPlayerInputGetKeyForActionstr)r   r   r   use_keyr   s       r#   HandleInputKey)TextInputBox.Show.<locals>.HandleInputKey   s   ***fkk6==9LLfmm4 }}!;;$"2"22(()_auv(,D%MM"''$--"89[[DNN2(()_auv(,D%MM"% G||~))5 ,,.44DDUDQv{{#w..r%   r   r   N)r   r4   r7   r,   r8   r9   r   r   	GetEngineGamePlayersActorGFxUIManagerShowTrainingDialogr3   r5   r:   SetPriorityr6   ApplyLayoutUObject	UFunctionFStructboolRegisterHook)r   r   s   ` r#   ShowTextInputBox.Show   s   T001dmm,$!&%//1==a@FFSSff+-JJ
 	%%dmm4%%'	/9#4#4 	/	@S@S 	/]f]n]n 	/sw 	/. 	UWkm{|r%   c                     U R                   SL $ )z
Gets if the text input box is currently being displayed.

Returns:
    True if the text input box is currently being displayed, False otherwise.
N)r:   r   s    r#   	IsShowingTextInputBox.IsShowing   s       D((r%   c                     U R                   c  [        R                  " S5        g[        R                  " SS5        U R                   R	                  5         SU l         g)z
Hides the text input box, without running any callbacks.

Displays a warning but does nothing if the text input box is not currently being displayed.
NzN[UserFeedback] Warning: tried to hide a text input box that was already closedr   r   )r:   r   Logr   Closer   s    r#   HideTextInputBox.Hide   sP     $MM` SUij! r%   Messagec                     g)z
Callback function intended to be overwritten. Called when the training box closes.

Args:
    Message: The html-escaped message the user input. Note this may be the empty string.
N )r   r   s     r#   r   TextInputBox.OnSubmit   s     	r%   	CharacterCurrentMessagePositionc                     g)ai  
Function called to determine if the character the user last input is may be added to the
 message, allowing for advanced input filtering.

Args:
    Character: The html-escaped character the user just input.
    CurrentMessage: The current message, html-escaped, before adding the new character.
    Position: The position of the new character in the message.
Tr   )r   r   r   r   s       r#   IsAllowedToWriteTextInputBox.IsAllowedToWrite   s     r%   keyeventc                    US;   a  US:X  a  SU l         gUS:X  a  SU l         gUS;   a  US:X  a  SU l        gUS:X  a  SU l        gUS:w  a  US:w  a  gU R                  (       Ga  US	:X  a%  [        S
R                  U R                  5      5        gUS:X  a4  [        S
R                  U R                  5      5        / U l        SU l        GOUS:X  a  [        5       R                  SS5      nUb  US
:X  a  gU H|  nU R                  US
R                  U R                  5      U R
                  5      (       d    GO&U R                  R                  U R
                  U5        U =R
                  S-  sl        M~     GOgUS:X  a   [        U R
                  S-
  S5      U l        GOUS:X  a3  [        U R
                  S-   [        U R                  5      5      U l        GOUS:X  a	  SU l        GOvUS:X  a  [        U R                  5      U l        GOTUS:X  aA  U R
                  S:w  a/  U R                  U R
                  S-
  	 U =R
                  S-  sl        GOUS:X  a;  U R
                  [        U R                  5      :w  a  U R                  U R
                  	 OXR                  ;   a  U R                  U   U R                      nO)US;   a"  U R                   (       d  UR                  5       nOgU R                  US
R                  U R                  5      U R
                  5      (       d  gU R                  R                  U R
                  U5        U =R
                  S-  sl        U R                  c  gU R                  R                   n[#        U R                  5      S/-   nSX`R
                     -   S-   X`R
                  '   U R                  R%                  US
R                  U5      5        U R                  R'                  5         g)a  
Function called any time the user inputs anything while the text input box is open.
Responsible for converting keypresses into the typed message

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
)	LeftShift
RightShiftr   Tr   FN)LeftControlRightControlr(   Cr   XVz

LeftRightHomeEnd	BackSpaceDeleteQWERTYUIOPASDFGHJKLZXCVBNMz  z<u>z</u>)r9   r   r/   r   r7   r8   r$   replacer   insertmaxminr,   r   lowerr:   DlgCaptionMarkupr   SetTextr   )r   r   r   	clipboard	charactertitlemessages          r#   r   TextInputBox._HandleInput   sB    --z'+$  !',$11z)-&  !).&A:%1*!!!czrwwt}}56rwwt}}56 ""#*,44VTB	$	R!*I00BGGDMM<RTXTcTcddMM(()DOOq(O	 "+ F]!$//A"5q9DOG^!$//A"5s4==7IJDOF]DOE\!$--0DOK!#MM$//A"561$H_#dmm"44MM$//2ll"ll3'(<(<=44++))+C((bggdmm.DdooVVMM  #6OOq O $ !!22 t}}%.#(7??+C#Cf#L !!%)9:%%'r%   )	r4   r5   r6   r3   r8   r   r9   r7   r:   )r   F   )r   N)__name__
__module____qualname____firstlineno____doc__r   __annotations__r   intr   r   r   r   r?   r   r   rB   r   r   r   r   r   r   r   r   r   __static_attributes__r   r%   r#   r1   r1   *   s     JM 3iO9,,--.K%S/* ,Ixc3h( (5z(5 	J(5 	J	(5
 	*(5 	z(5 	z(5 	(5 	
(5 	
(5 	z(5 	(5 	(5 	
(5 	
(5  	Z!(5" 	Z#(5$ 	z%(5& 	j'(5( 	j)(5* 	Z+(5, 	z-(5. 	z/(50 	j1(52 	j3(54 	[5(56 	7(58 	:9(5: 	*;(5< 	z=(5> 	-?(5@ 	A(5B 	
C(5D 	ZE(5F 	G(5H  O(5GXd3c3h/01 (Z ! !! ! 	!
 ! 
!B(}T)4 )!"  
# 
s 
c 
VZ 
[( [(C [(D [(r%   r1   )r   typingr   r   r   r   r   r	   ossyspathr   dirnameabspath__file__	_lib_pathappendr
   r   r   r   remover   r$   r/   r1   r   r%   r#   <module>r     s     8 8  	 
GGLL)BCXN	 	  9 9 	  	#S 	#T 	#f(8 f(r%   