Advertisement
Guest User

Untitled

a guest
May 1st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. import BigWorld
  2. from gui import SystemMessages
  3. from ResMgr import openSection as _openSection
  4. from BigWorld import wg_getProductVersion as _productVersion
  5. from gui.Scaleform.daapi.view.lobby.LobbyView import LobbyView
  6.  
  7. class testClass(object):
  8.    
  9.     def __init__(self):
  10.           g_hookUtil.INJECT(LobbyView, '_populate')(self.__hooked_populate)
  11.    
  12.     def __hooked_populate(self, baseMethod, baseObject):
  13.         baseMethod(baseObject)
  14.         SystemMessages.pushMessage("Mod Enable", SystemMessages.SM_TYPE.Warning)
  15.        
  16. def _overrideMethod(handler, cls, method):
  17.     orig = getattr(cls, method)
  18.     new = lambda *args, **kwargs: handler(orig, *args, **kwargs)
  19.     setattr(cls, method, new if type(orig) is not property else property(new))
  20.  
  21. def _overrideStaticMethod(handler, cls, method):
  22.     orig = getattr(cls, method)
  23.     new = staticmethod(lambda *args, **kwargs: handler(orig, *args, **kwargs))
  24.     setattr(cls, method, new if type(orig) is not property else property(new))
  25.  
  26. def _hookDecorator(func):
  27.     def _oneDecorator(*args, **kwargs):
  28.         def _twoDecorator(handler):
  29.             func(handler, *args, **kwargs)
  30.         return _twoDecorator
  31.     return _oneDecorator
  32.    
  33. class hookUtil():
  34.    
  35.     VERSION = tuple(map(int, _productVersion().split('.')))
  36.     PATH = _openSection('../paths.xml')['Paths'].values()[0].asString    
  37.     MODS = '/'.join([PATH, 'scripts', 'client', 'mods'])
  38.     GUI_MODS = '/'.join([PATH, 'scripts', 'client', 'gui', 'mods'])
  39.     INJECT = staticmethod(_hookDecorator(_overrideMethod))
  40.     OVERRIDE_STATIC = staticmethod(_hookDecorator(_overrideStaticMethod))
  41.    
  42. g_hookUtil = hookUtil()
  43. g_testClass = testClass()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement