
    Jb.a                     P   % S SK r S SKrS SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
  S SKJrJr  S SKJr  S SKJrJrJrJrJr  S SKJrJrJrJrJrJrJrJrJr  S SKJr  \\
   \ S	'    S S
KJ!r!  S SK"J#r#J$r$  \ RL                  " 5       S:  a  \ RN                  " S5        \(S:X  a  S SK)r) \*e\\0\4   r1Sr2\0\ S'   SS0r3\\0\04   \ S'   0 \3ESSS.Er4\\0\04   \ S'   \Rj                  Rm                  \Rj                  Ro                  \/5      S5      r8\0\ S'   0 r9\1\ S'    \Rt                  " \8SSS9 r;\Rx                  " \;5      r9SSS5        \ R~                  " SS 5      r@\ R                  \ S!'   \@c  \B" S"5      eS#\0S$\\0\04   S%\04S& jrCS'\ R                  S(\DS)\DS%\04S* jrE " S+ S,\R                  5      rG " S- S.\R                  5      rIS6S/ jrJS6S0 jrK " S1 S2\5      rL\L" 5       rM\(S:X  a  \ RN                  " S3\MR                   S435        \ H  rO\OR                  \MR                  :X  d  M  \OR                  (       a  \OR                  5         \R                  " \O5        \ RN                  " S3\MR                   S535        \OR                  R                  \MR                  lT          O   \" \M5        g! \% a    Sr! GNCf = f! \* a6    \)RV                  " 5       S   RX                  RZ                  R\                  r/ GNNf = f! , (       d  f       GN= f! \=\R|                  4 a     GNf = f)7    N)Counter)	dataclass)
ModuleType)AnyClassVar)DictOptionalSequenceTupleUnion)	EnabledSaveTypeGameHookModsModTypesOptionsRegisterModSaveModSettingsSDKMod)legacy_get_part_nameCommandExtensions)r   )obj_name_splitterparse_object)r      	   z[PythonPartNotifier] Warning: You're using an old SDK version, which doesn't support unicode. Some item card text will get garbled. Update the SDK to prevent this.__main__z#FFDEADEMPHASIS_COLOURReliczOz KitTPS_TYPE_REPLACEMENTSScavzBouncing Bazza)BanditzBouncing BonnyLEGACY_TPS_REPLACEMENTSzpart_names.json.gzPART_NAMES_FILE
PART_NAMESrtutf8)encodingGFxMoviePlayerzGFxUI.Default__GFxMoviePlayerDEFAULT_MOVIE_PLAYERz'Unable to find default 'GFxMoviePlayer'textreplacementsreturnc                 Z    UR                  5        H  u  p#U R                  X#5      n M     U $ )z
Given a dict of terms to replacements, apply all replacements to the given text.

Args:
    text: The text to edit.
Returns:
    The given text with TPS terms replaced.
)itemsreplace)r+   r,   termreplacements       fZ:\mnt\Skyabridged\SteamLibrary\steamapps\common\Borderlands 2\sdk_mods\PythonPartNotifier\__init__.pyapply_replacementsr4   E   s-     *//1||D. 2K    part	show_slot	show_typec                 :   U R                  U 5      nU[        ;   a  [        U   nUS   nUS   nUS   n US   [        R                  " 5       R                     n[        R                  U5      n[        R                  " 5       [        R                  :X  a  [        U[        5      nUnU(       a  USU-   -  nU(       a  USU-   -  nU$ [        XU5      n[        R                  " 5       [        R                  :X  a  [        U[        5      nU$ ! [
         a     Nf = f)z
Gets the name of a single part object.

Args:
    part: The part to name.
    show_slot: If to show the slot the part is intended for.
    show_type: If to show the item type the part is intended for.
Returns:
    The part's name.
nameslottypegame_overrides )PathNamer%   r   
GetCurrentr:   KeyErrorr*   ResolveDataStoreMarkupTPSr4   r    r   r#   )	r6   r7   r8   obj_name	part_infor:   r;   	item_typeoutputs	            r3   get_single_part_namerH   S   s	    }}T"H:x(	f%f%"6*		-.t/@/E/EFD $::4@??(*96KLIcIo%FcDj F &dyA??('0GHF'  		s   %D 
DDc            	          ^  \ rS rSr% Sr\\S4   \S'    SS\S\S\\S4   S\4U 4S jjjr	S	\
R                  S
\S\S\4S jrSrU =r$ )
PartOption~   z}
Custom boolean option for determining what part slots to show.

Attributes:
    Slots: The part slots this option controls.
.SlotsCaptionStartingValueDescriptionc                 2   > [         TU ]  XU5        X0l        g N)super__init__rL   )selfrM   rN   rL   rO   	__class__s        r3   rS   PartOption.__init__   s     	}=
r5   itemr7   r8   r-   c                 \   [        5       nU R                   H*  n[        UR                  U5      nUc  M  XF==   S-  ss'   M,     [	        U5      S:  a  gU R
                   S[         S3nSnU H4  nU(       d  US-  nSnU[        XbU5      -  nXF   S:  d  M*  USXF    3-  nM6     US-  nU$ )	aH  
Names all parts covered by this option on the given item.

Args:
    item: The item to look for parts on.
    show_slot: If to show the slot the part is intended for.
    show_type: If to show the item type the part is intended for.
Returns:
    A string containing all found part names, or an empty string if none were found.
    z: <font color='z'>T, z xz</font>
)r   rL   getattrDefinitionDatalenrM   r   rH   )	rT   rW   r7   r8   part_countsr;   r6   r+   firsts	            r3   name_item_partsPartOption.name_item_parts   s     7>iJJD4..5D|"	  {a,,.?rBDE()DDD 1$"[./00   	r5   )rL   )z3Should the part be shown in the description or not.)__name__
__module____qualname____firstlineno____doc__r   str__annotations__boolrS   	unrealsdkUObjectra   __static_attributes____classcell__rU   s   @r3   rJ   rJ   ~   s     c? Q  S#X	
  "I$5$5 "$ "SW "\_ " "r5   rJ   c                   n   ^  \ rS rSr% Sr\\   \S'   \\S'   SS.S\S\S\\   S\	S	S
4
U 4S jjjr
SrU =r$ )ItemClassOption   zq
Custom nested option for specific item classes.

Attributes:
    ItemClass: The item class this option controls
Children	ItemClassFIsHiddenrM   rv   r-   Nc                \   > [         TU ]  USUS S R                  5        S3UUS9  X l        g )NzConfigure which r   z parts should be shown.ru   )rR   rS   lowerrt   )rT   rM   rt   rs   rv   rU   s        r3   rS   ItemClassOption.__init__   sD     	ws|11344KL	 	 	
 #r5   )rt   )rc   rd   re   rf   rg   r
   rJ   ri   rh   rj   rS   rm   rn   ro   s   @r3   rq   rq      s^     z""N ## # :&	# # 
# #r5   rq   c            	        ^^ [         c  g[         " S S5      5       m " UU4S jS[        R                  5      mS[        R                  SS4S jn [         R
                  " S	U S
SS9nUR                  SSS9  UR                  SSS9  UR                  SSS9  UR                  SSS9  UR                  SSSTTR                  S4SS9  UR                  SSSSS 9  S[        R                  SS4S! jn[         R
                  " S"U[        S#S$9nUR                  SS%S9  S[        R                  SS4S& jn[         R
                  " S'U[        S(S$9nUR                  SS)S9  g)*zCRegisters all console command, if Command Extensions is available. Nc                   .    \ rS rSr% Sr\\S'   \\S'   Srg)'register_commands.<locals>.GameOverride   z
Dataclass to store game overrides, for when adding new names via command extensions.

Attributes:
    game: The game this override is for.
    name: The name to use if this override applies.
gamer:    N)	rc   rd   re   rf   rg   r   ri   rh   rm   r   r5   r3   GameOverrider|      s    	 
	r5   r   c                     > \ rS rSr% Sr\R                  \R                  \R                  S.r	\
\\\4      \S'   SSR                  \" \\R                   R#                  5       5      5      -   S-   r\
\   \S'   S	R                  \" \\R                   R#                  5       5      5      r\
\   \S
'    SS\R,                  S\R.                  S\\\\   S4   S\\   SS4
U U4S jjjrSrg)-register_commands.<locals>.GameOverrideAction   z{
Custom Action which parses a game-name pair into a `GameOverride` object. Acts like the
 default append action otherwise.
)bl2tpsaodkLOWER_GAME_MAP{,}GAME_CHOICES_METAVARr[   GAME_CHOICES_ERRNparser	namespacevaluesoption_stringr-   c                 J  > Uu  pVT
R                   R                  UR                  5       S 5      nUc)  [        R                  " U SU< ST
R
                   S35      e[        X R                  S 5      nUc  / n[        X R                  U5        UR                  T	" Xv5      5        g )Nzinvalid choice: z (choose from ))
r   getrx   argparseArgumentErrorr   r\   destsetattrappend)rT   r   r   r   r   game_stroverrider~   r/   r   GameOverrideActions            r3   __call__6register_commands.<locals>.GameOverrideAction.__call__   s     "(H%44889I4PD|,,&xl.ASAdAd@eefg 
 Iyy$7E}	99e4LLd56r5   r   rQ   )rc   rd   re   rf   rg   r   BL2rC   AoDKr   r   r   rh   ri   joinmap_member_map_keysr   reprr   r   ArgumentParser	Namespacer   r
   r   r	   r   rm   )r   r   s   r3   r   r      s   	 8888II5
c4i1 	
 /2CHHSdFWFWF\F\F^=_4`.`cf.fhsmf*.))Cd>O>O>T>T>V4W*X(3-X ,0	7++	7  ))	7 #x}d23		7
 $C=	7 	7 	7r5   r   argsr-   c                    [        U R                  5      nUc  gUR                  U5      nU R                  U R                  U R
                  S.nU R                  (       a;  0 nU R                   H%  nUR                  XER                  R                  '   M'     XCS'   U R                  (       a+  [        R                  " [        R                  " USSS95        gU[        U'   g)z^
Handles `name_part` command invocations.

Args:
    args: The passed command line arguments.
N)r:   r;   r<   r=      Tindent	sort_keys)r   r6   r?   r:   r;   r<   game_overrider~   dry_runrk   Logjsondumpsr%   )r   r6   	part_namerE   r=   r   s         r3   set_handler&register_commands.<locals>.set_handler  s     DII&<MM$'	 IIIIII
	 -/N ..5=]]}}112 /*8&'<<MM$**YqDIJ$-Jy!r5   set_part_namezwSets the name used for the given part. Note that this command is very sensitive to punctuation, best to quote all args.zThe 'name', 'type', and 'slot' arguments may include both text and html-style markup - "[shock]Shock[-shock] <font color='#3c8eff'>Rare</font>".)descriptionepilogr6   zThe part to set the name of.)helpr:   zThe part's name, e.g. 'Bandit'.r<   z7The item type the part is intended for, e.g. 'Shotgun'.r;   z7The slot the part is intended to go into, e.g. 'Stock'.z-gz--game-override   NAMEzBSet game-specific part name overrides. May be used multiple times.)nargsactionmetavarr   z-yz	--dry-run
store_truezxDon't modify anything, just print what the command would set the name to. Useful to check it's being parsed as expected.)r   r   c                    [        U R                  5      nUc  gUR                  U5      nU[        ;   a2  [        R
                  " [        R                  " [        U   SSS95        g[        R
                  " U< S35        [        R
                  " S5        [        R
                  " S5        S H:  nS H1  n[        XU5      n[        R
                  " S	U   S
U   -   U-   5        M3     M<     g)zb
Handles `get_part_name` command invocations.

Args:
    args: The passed command line arguments.
Nr   Tr   z9 does not have defined name info. Using the legacy namer:zType | Slot | Namez-----+-----+-------)FT)z   N   |z   Y   |)z  N   | z  Y   | )	r   r6   r?   r%   rk   r   r   r   r   )r   r6   r   r8   r7   r:   s         r3   get_handler&register_commands.<locals>.get_handlerC  s     DII&<MM$'	
"MM$**Z	%:1PTUVMMYM)bcdMM./MM/0*	!.I/KDMM0;29=> "/ +r5   get_part_namez2Gets the stored part name info for the given part.)splitterr   zThe part to get the name of.c                     [        U R                  5      nUc  gUR                  U5      nU[        ;   a  [        U	 g[        R
                  " U< S35        g)ze
Handles `delete_part_name` command invocations.

Args:
    args: The passed command line arguments.
Nz! does not have defined name info.)r   r6   r?   r%   rk   r   )r   r6   r   s      r3   delete_handler)register_commands.<locals>.delete_handlerg  sL     DII&<MM$'	
"9%MMYM)JKLr5   delete_part_namez5Deletes the stored part name info for the given part.z&The part to delete the stored name of.)	r   r   r   Actionr   RegisterConsoleCommandadd_argumentr   r   )r   
set_parserr   
get_parserr   delete_parserr   r   s         @@r3   register_commandsr      s    	 	 	#7 #7X__ #7J.(,, . .: #994MJ F)GHF)JKF)bcF)bc*#88&AQ	   k4	  (,,  8 #99"H	J F)GHMX// MD M" &<<"K	M v,TUr5   c                      [         c  g[         R                  " S5        [         R                  " S5        [         R                  " S5        g)zFUnregisters all console commands, if Command Extensions is available. Nr   r   r   )r   UnregisterConsoleCommandr   r5   r3   unregister_commandsr     s6     ..?..?../ABr5   c            	         ^  \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S	'   \
R                  r\
\S
'   \R                  r\\S'   SSS.r\\\4   \S'   \R&                  \S'   \R&                  \S'   \R(                  \S'   \R&                  \S'   S"S jrS\SS4U 4S jjrS"S jr\" S5      S\R4                  S\R6                  S\R8                  S\4S j5       rS"U 4S jjrS"U 4S  jjr S!r!U =r"$ )#PythonPartNotifieri  zPython Part NotifierName	apple1417AuthorzLets you show all parts on your items and weapons, even if other mods have modified them.

Make sure to check out the options menu to customize what exactly is shown.rO   z1.9VersionTypesSaveEnabledStateEnableReset Options)EnterRSettingsInputs
SlotOption
TypeOptionFontSizeOptionRemoveOptionr-   Nc                 $    U R                  5         g rQ   )SetDefaultOptionsrT   s    r3   rS   PythonPartNotifier.__init__  s     r5   r   c                 h   > US:X  a  U R                  5         [        U 5        g [        TU ]  U5        g )Nr   )r   r   rR   SettingsInputPressed)rT   r   rU   s     r3   r   'PythonPartNotifier.SettingsInputPressed  s,    _$""$D!G(0r5   c                 t   [         R                  " SSS5      U l        [         R                  " SSS5      U l        [         R                  " SSSS	S
S5      U l        [         R                  " SSS5      U l        U R                  U R                  U R
                  U R                  [        SS[        SSS5      [        SSS5      [        SSS5      [        SSS5      [        SSS5      [        SSS5      [        SSS5      [        SSS 5      [        S!SS"5      [        S#SS$5      4
5      [        S%S&[        SSS'5      [        S(SS)5      [        SSS*5      [        S+SS,5      [        SSS-5      [        S#SS.5      [        S/SS0S15      45      [        S2S3[        SSS'5      [        S4SS55      [        S6SS75      [        S8SS95      [        S:SS)5      [        SSS-5      [        S;SS*5      [        S<SS=5      [        S>SS,5      [        S#SS.5      4
5      [        S?S@[        SASS*5      [        SBSS)5      [        SCSS,5      [        SDSS-5      [        S#SS.5      [        S/SSES15      45      [        SFSG[        SSS75      [        SHSS=5      [        SISS*5      [        SJSS)5      [        SKSS,5      [        SLSS'5      [        SMSS95      [        SNSS55      [        S#SS.5      [        S/SS-S15      4
[        R                  " 5       [        R                  :H  SO9[        SPSG[        SSS75      [        SHSS=5      [        SISS*5      [        SJSS)5      [        SKSS,5      [        SLSS'5      [        SMSS95      [        SNSS55      [        S#SS.5      [        S/SS-S15      4
[        R                  " 5       [        R                  :g  SO9/
U l         gQ)Rz;Sets the options array to use new options all at defaults. zInclude Item Typez=Should part names include the item type they're intended for.FzInclude Part Slotsz8Should part names include the slot they're intended for.z	Font SizezSWhat font size should the parts text use. Decrease this if text is getting cut off.         rY   zRemove DescriptionszZShould the default descriptions be removed to create more space for the part descriptions.WeaponsWillowWeapon	AccessoryT)Accessory1PartDefinitionz2nd Accessory)Accessory2PartDefinitionBarrel)BarrelPartDefinitionBody)BodyPartDefinitionElement)ElementalPartDefinitionGrip)GripPartDefinitionMaterial)MaterialPartDefinitionSight)SightPartDefinitionStock)StockPartDefinition
Definition)WeaponTypeDefinitionShieldsWillowShield)DeltaItemPartDefinitionBattery)BetaItemPartDefinition)AlphaItemPartDefinition	Capacitor)GammaItemPartDefinition)MaterialItemPartDefinition)ItemDefinitionExtras)EpsilonItemPartDefinitionZetaItemPartDefinitionEtaItemPartDefinitionThetaItemPartDefinitionzPShould parts in slots that aren't normally used be shown if they contain a part.GrenadesWillowGrenadeModzBlast Radius)r  zChild Count)r  Damage)r  DeliveryPayloadzStatus Damage)r  Triggerz
Class ModsWillowClassModSpecializationPrimary	SecondaryPenalty)r  r  r  r  r  RelicsWillowArtifactUpgradeAlphaBetaGammaDeltaEpsilonZetaru   zOz KitsN)r   Booleanr   r   Sliderr   r   rq   rJ   r   r@   rC   r   s    r3   r   $PythonPartNotifier.SetDefaultOptions  s#   !//K

 "// F

 &nna2q

 $OO!	
 OOOO>{D2OP7TUx/HIvu.EFy%1MNvt-DEz52MNw.FGw.FG|U4MN, >{E3OPy$0KLvt-IJ{D2NOz52QR|U4GHx 0
 jk,  .{E3OP~t5PQ}d4NOx0NOz41LMz52QRy%1MN7STy$0LM|U4GH1 ./7STy$0KL{D2NOy$0OP|U4GHx 0 jk1  *vu.HIy$0LM w/KLvu.IJw/KLw/KLy%1OPvu.IJ|U4GHx 0ik- !OO-9!$ +vu.HIy$0LM w/KLvu.IJw/KLw/KLy%1OPvu.IJ|U4GHx 0ik. !OO-9!ge
r5   z*WillowGame.ItemCardGFxObject.SetItemCardExcallerfunctionparamsc                 @   UR                   R                  nUc  gSnU R                   H  n[        U[        5      (       d  M  UR
                  UR                  R                  :w  a  M@  UR                   HS  nUR                  (       d  M  XWR                  UU R                  R                  U R                  R                  5      -  nMU       O   g[        U5      S:X  a  gUR                  5       nUb  U R                  R                  (       a  SnUSU R                   R                   S3-  nX-  nUS-  nS["        R$                  S["        R&                  S	["        R(                  S
[*        4S jn	["        R,                  " S[.        U	5        UR1                  U5        g)zl
This function is called whenever an item card is created - exactly when we need to add
all the parts text.
TrZ   r   z<font size="z" color="#FFFFFF">z</font>r)  r*  r+  r-   c                 :    [         R                  " S[        5        g)N(WillowGame.ItemCardGFxObject.SetFunStatsF)rk   
RemoveHook__file__)r)  r*  r+  s      r3   SetFunStats5PythonPartNotifier.SetItemCardEx.<locals>.SetFunStatsY  s      !KXVr5   r.  )InventoryItemObjectPointerr   
isinstancerq   rt   Classr   rs   CurrentValuera   r   r   r^   GenerateFunStatsTextr   r   rk   rl   	UFunctionFStructrj   RegisterHookr0  r1  )
rT   r)  r*  r+  rW   	part_textoptionchild_optionr+   r1  s
             r3   SetItemCardEx PythonPartNotifier.SetItemCardEx*  sw    ##11<	llFfo664::??2 &#0099OO00OO00 	 !0  #"  y>Q ((*<4,,99D- 3 3 @ @AAVWW			 1 1 	Y=P=P 	ZcZkZk 	pt 	 	I8U`a4 r5   c                 4   > [        5         [        TU ]	  5       $ rQ   )r   rR   r   rT   rU   s    r3   r   PythonPartNotifier.Enablec  s    w~r5   c                 4   > [        5         [        TU ]	  5       $ rQ   )r   rR   DisablerB  s    r3   rE  PythonPartNotifier.Disableg  s    w  r5   )r   r   r   r   r   r-   N)#rc   rd   re   rf   r   rh   ri   r   rO   r   r   Utilityr   r   LoadWithSettingsr   r   r   r   r&  r'  rS   r   r   r   rk   rl   r9  r:  rj   r?  r   rE  rm   rn   ro   s   @r3   r   r     s   &D#&FC	V  
 GS&&E8&(7(H(HoH &NDcN 
 NN"//!!13 14 1}
~ 

676I$5$5 6ATAT 6^g^o^o 6tx 6 86p ! !r5   r   [z] Manually loadedz] Removed last instancerG  )Urk   r   gzipr   oscollectionsr   dataclassesr   typesr   typingr   r   CounterTyper   r	   r
   r   r   Mods.ModMenur   r   r   r   r   r   r   r   r   !Mods.PythonPartNotifier.PartNamerr   ri   r   Mods.CommandExtensions.builtinsr   r   ImportError
GetVersionr   rc   sysNotImplementedErrorexc_infotb_framef_codeco_filenamer0  rh   JSONr   r    r#   pathr   dirnamer$   r%   openfileloadOSErrorJSONDecodeError
FindObjectr*   rl   RuntimeErrorr4   rj   rH   r&  rJ   Nestedrq   r   r   r   instancer   mod	IsEnabledrE  removerU   rd   r   r5   r3   <module>rl     s       	  !    ) 9 93 3 3 BJ' '&O I% MM	Z
 zB!! CH~    X) tCH~ ++&+ c3h  ww||BGGOOH$=?ST T
D 		?D6	:dYYt_
 
;
 +4*>*>?OQp*q i'' q
@
AAS S#X 3 (y00 (T (d (WZ (V5 5p#gnn #6mV`C_! _!D zMMAhmm_$56788x}}$}}KKMMAhmm_,CDE -0MM,D,DH)  H I     B<<>"%..55AAB* 
;	:%%& 		sT   )J/ )J> L .K=L /J;:J;>8K:9K:=
LL L L%$L%