VasyaPRO_2014 Posted January 7, 2016 Share Posted January 7, 2016 Здравствуйте уважаемые мододелы. Хотелось бы задать несколько вопросов знающим людям. 1.Что делает декоратор (или как он там называется) @staticmethod и где вообще можно посмотреть что делают любые декораторы? 2.Как можно перехватить нажатие клавиш, к примеру чтобы при нажатии клавиши перезагрузить конфиг? 3.Хочу при нажатии таб использовать html строки вместо название танка либо никнейма игрока (либо любой другой способ сделать эти поля цветными). Есть к примеру код: import BigWorld from gui.battle_control.battle_arena_ctrl import BattleArenaController old__makeHash = BattleArenaController._makeHash def new__makeHash(self,index, playerFullName, vInfoVO, vStatsVO, viStatsVO, ctx, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited, isEnemy): makeHash = old__makeHash(self, index, playerFullName, vInfoVO, vStatsVO, viStatsVO, ctx, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited, isEnemy) makeHash['vehicle']='<font color="ff0000">'+vInfoVO.vehicleType.shortName+'</font>' return makeHash BattleArenaController._makeHash = new__makeHash На выходе имею: хотя к примеру этот мод: http://forum.worldoftanks.eu/index.php?/topic/455834-0913statistics-no-xvm/ вроде делает тоже самое и работает. @ Quote Link to comment Short link Share on other sites More sharing options...
SkepticalFox Posted January 7, 2016 Share Posted January 7, 2016 (edited) makeHash['vehicle']='<font color="ff0000">'+vInfoVO.vehicleType.shortName+'</font>'makeHash['vehicle']="<font color='#ff0000'>%s</font>" % vInfoVO.vehicleType.shortName может так? Edited January 7, 2016 by ShadowHunterRUS @ Quote Link to comment Short link Share on other sites More sharing options...
VasyaPRO_2014 Posted January 7, 2016 Author Share Posted January 7, 2016 makeHash['vehicle']="<font color='#ff0000'>%s</font>" % vInfoVO.vehicleType.shortName может так? не работает( @ Quote Link to comment Short link Share on other sites More sharing options...
SkepticalFox Posted January 7, 2016 Share Posted January 7, 2016 не работает(Значит слишком низко перехватил подмену... @ Quote Link to comment Short link Share on other sites More sharing options...
VasyaPRO_2014 Posted January 7, 2016 Author Share Posted January 7, 2016 Значит слишком низко перехватил подмену... А как иначе? Цвет можно менять 100% ибо даже при загрузке игроки меняют свой цвет с серого на более светлый. @ Quote Link to comment Short link Share on other sites More sharing options...
SkepticalFox Posted January 7, 2016 Share Posted January 7, 2016 А как иначе?makeHash['userName'] там это работает @ Quote Link to comment Short link Share on other sites More sharing options...
VasyaPRO_2014 Posted January 7, 2016 Author Share Posted January 7, 2016 makeHash['userName'] там это работает Странно, у меня не работает. old__makeHash = BattleArenaController._makeHash def new__makeHash(self,index, playerFullName, vInfoVO, vStatsVO, viStatsVO, ctx, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited, isEnemy): makeHash = old__makeHash(self, index, playerFullName, vInfoVO, vStatsVO, viStatsVO, ctx, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited, isEnemy) playerVO = vInfoVO.player makeHash['userName']="<font color='#FF0000'>%s</font>" % playerVO.getPlayerLabel() return makeHash BattleArenaController._makeHash = new__makeHash @ Quote Link to comment Short link Share on other sites More sharing options...
VasyaPRO_2014 Posted January 8, 2016 Author Share Posted January 8, 2016 Может кто либо ответить на остальные вопросы? В частности вопрос №2? @ Quote Link to comment Short link Share on other sites More sharing options...
Ekspoint Posted January 9, 2016 Share Posted January 9, 2016 Может кто либо ответить на остальные вопросы? В частности вопрос №2? в исходниках модов спотера есть пример @ Quote Link to comment Short link Share on other sites More sharing options...
spoter Posted January 10, 2016 Share Posted January 10, 2016 Обработка нажатий клавиш в бою, Если не нужно именно в бою, то меняйте isInBattle import Keys import BigWorld import game from gui import InputHandler from gui.app_loader import g_appLoader def key_pressed_function(): print 'pressed' def inject_handle_key_event(event): is_down, key, mods, is_repeat = game.convertKeyEvent(event) isInBattle = g_appLoader.getDefBattleApp() #battle start check try: if isInBattle: if key is Keys.KEY_E and is_down and mods is Keys.MODIFIER_ALT: key_pressed_function() except Exception as e: print ('error in inject_handle_key_event', e) InputHandler.g_instance.onKeyDown += inject_handle_key_event InputHandler.g_instance.onKeyUp += inject_handle_key_event 2 @ Quote Link to comment Short link Share on other sites More sharing options...
VasyaPRO_2014 Posted January 10, 2016 Author Share Posted January 10, 2016 Обработка нажатий клавиш в бою, Если не нужно именно в бою, то меняйте isInBattle import Keys import BigWorld import game from gui import InputHandler from gui.app_loader import g_appLoader def key_pressed_function(): print 'pressed' def inject_handle_key_event(event): is_down, key, mods, is_repeat = game.convertKeyEvent(event) isInBattle = g_appLoader.getDefBattleApp() #battle start check try: if isInBattle: if key is Keys.KEY_E and is_down and mods is Keys.MODIFIER_ALT: key_pressed_function() except Exception as e: print ('error in inject_handle_key_event', e) InputHandler.g_instance.onKeyDown += inject_handle_key_event InputHandler.g_instance.onKeyUp += inject_handle_key_event Спасибо огромное. @ Quote Link to comment Short link Share on other sites More sharing options...
Ekspoint Posted January 10, 2016 Share Posted January 10, 2016 import Keys from BigWorld import player from gui import InputHandler from BigWorld import isKeyDown from Avatar import PlayerAvatar from game import convertKeyEvent from Account import PlayerAccount class HotKeys: @staticmethod def One(ParseKeys): if len(ParseKeys.split(' and ')) == 2: return getattr(Keys, ParseKeys.split(' and ')[1]) return getattr(Keys, ParseKeys.split(' and ')[0]) @staticmethod def Two(ParseKeys): if len(ParseKeys.split(' and ')) == 2: return isKeyDown(getattr(Keys, ParseKeys.split(' and ')[0])) return True def New_onHandleKeyEvent(event): Old_onHandleKeyEvent(event) isDown, key, mods, isRepeat = convertKeyEvent(event) if isinstance(player(), PlayerAccount): ## Ангар if key == HotKeys.One('KEY_N and KEY_M') and isDown: if HotKeys.Two('KEY_N and KEY_M'): print '' # Сюда пишем свой код if isinstance(player(), PlayerAvatar): ## Бой if key == HotKeys.One('KEY_N and KEY_M') and isDown: if HotKeys.Two('KEY_N and KEY_M'): print '' # Сюда пишем свой код Old_onHandleKeyEvent = InputHandler.g_instance.handleKeyEvent InputHandler.g_instance.handleKeyEvent = New_onHandleKeyEvent """ def New_onHandleKeyEvent(self, isDown, key, mods): Old_onHandleKeyEvent(self, isDown, key, mods) if key == HotKeys.One('KEY_N and KEY_M') and isDown: if HotKeys.Two('KEY_N and KEY_M'): print '' # Сюда пишем свой код Old_onHandleKeyEvent = PlayerAvatar.handleKey PlayerAvatar.handleKey = New_onHandleKeyEvent """ 1 @ Quote Link to comment Short link Share on other sites More sharing options...
adjgam Posted January 10, 2016 Share Posted January 10, 2016 (edited) del Edited January 15, 2016 by adjgam 1 @ Quote Link to comment Short link Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.