Electron_i_k Posted June 16, 2016 Share Posted June 16, 2016 Подскажите, как сделать ссылку активной, которая ведёт на внешний сайт, в клиенте WoT в центре уведомлений. href чёт не работает. Заранее спасибо. @ Quote Link to comment Short link Share on other sites More sharing options...
Ekspoint Posted June 16, 2016 Share Posted June 16, 2016 (edited) import re import BigWorld from gui.SystemMessages import SM_TYPE from gui.SystemMessages import pushMessage from notification.settings import NOTIFICATION_TYPE from gui.Scaleform.daapi.view.lobby.LobbyView import LobbyView from notification.actions_handlers import NotificationsActionsHandlers def new_handleAction(self, model, typeID, entityID, actionName): if typeID == NOTIFICATION_TYPE.MESSAGE and re.match('https?://', actionName, re.I): BigWorld.wg_openWebBrowser(actionName) else: old_handleAction(self, model, typeID, entityID, actionName) old_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_handleAction def NewLobbyView_populate(self): OldLobbyView_populate(self) global Show if not Show: Show = True pushMessage(u'<font color="#12c812">При поддержке сайта</font>' + ' ' + u'<a href="event:http://www.koreanrandom.com"><font color="#eb2222">korean</font></a>', SM_TYPE.GameGreeting) Show = False OldLobbyView_populate = LobbyView._populate LobbyView._populate = NewLobbyView_populate Edited June 16, 2016 by Ekspoint 3 @ Quote Link to comment Short link Share on other sites More sharing options...
Electron_i_k Posted June 16, 2016 Author Share Posted June 16, 2016 import re import BigWorld from gui.SystemMessages import SM_TYPE from gui.SystemMessages import pushMessage from notification.settings import NOTIFICATION_TYPE from gui.Scaleform.daapi.view.lobby.LobbyView import LobbyView from notification.actions_handlers import NotificationsActionsHandlers def new_handleAction(self, model, typeID, entityID, actionName): if typeID == NOTIFICATION_TYPE.MESSAGE and re.match('https?://', actionName, re.I): BigWorld.wg_openWebBrowser(actionName) else: old_handleAction(self, model, typeID, entityID, actionName) old_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_handleAction def NewLobbyView_populate(self): OldLobbyView_populate(self) global Show if not Show: Show = True pushMessage(u'<font color="#12c812">При поддержке сайта</font>' + ' ' + u'<a href="event:http://www.koreanrandom.com"><font color="#eb2222">korean</font></a>', SM_TYPE.GameGreeting) Show = False OldLobbyView_populate = LobbyView._populate LobbyView._populate = NewLobbyView_populate спасибо @ Quote Link to comment Short link Share on other sites More sharing options...
goofy67 Posted June 18, 2016 Share Posted June 18, 2016 import re import BigWorld from gui.SystemMessages import SM_TYPE from gui.SystemMessages import pushMessage from notification.settings import NOTIFICATION_TYPE from gui.Scaleform.daapi.view.lobby.LobbyView import LobbyView from notification.actions_handlers import NotificationsActionsHandlers def new_handleAction(self, model, typeID, entityID, actionName): if typeID == NOTIFICATION_TYPE.MESSAGE and re.match('https?://', actionName, re.I): BigWorld.wg_openWebBrowser(actionName) else: old_handleAction(self, model, typeID, entityID, actionName) old_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_handleAction def NewLobbyView_populate(self): OldLobbyView_populate(self) global Show if not Show: Show = True pushMessage(u'<font color="#12c812">При поддержке сайта</font>' + ' ' + u'<a href="event:http://www.koreanrandom.com"><font color="#eb2222">korean</font></a>', SM_TYPE.GameGreeting) Show = False OldLobbyView_populate = LobbyView._populate LobbyView._populate = NewLobbyView_populate Другая возможность: import re from gui.shared import g_eventBus, events from gui.SystemMessages import pushMessage, SM_TYPE from notification.actions_handlers import NotificationsActionsHandlers def new_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName): regex = re.compile( r'^https?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' r'(?::\d+)?' r'(?:/?|[/?]\S+)$', re.IGNORECASE ) if regex.match(actionName) is None: return old_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName) g_eventBus.handleEvent(events.OpenLinkEvent(events.OpenLinkEvent.SPECIFIED, actionName)) return None old_NotificationsActionsHandlers_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_NotificationsActionsHandlers_handleAction msg = '<font color="#12c812">Forum: </font><a href="event:http://www.koreanrandom.com"><font color="#eb2222">Korean</font></a>' pushMessage(msg, SM_TYPE.GameGreeting) @ Quote Link to comment Short link Share on other sites More sharing options...
Ekspoint Posted June 18, 2016 Share Posted June 18, 2016 Другая возможность: import re from gui.shared import g_eventBus, events from gui.SystemMessages import pushMessage, SM_TYPE from notification.actions_handlers import NotificationsActionsHandlers def new_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName): regex = re.compile( r'^https?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' r'(?::\d+)?' r'(?:/?|[/?]\S+)$', re.IGNORECASE ) if regex.match(actionName) is None: return old_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName) g_eventBus.handleEvent(events.OpenLinkEvent(events.OpenLinkEvent.SPECIFIED, actionName)) return None old_NotificationsActionsHandlers_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_NotificationsActionsHandlers_handleAction msg = '<font color="#12c812">Forum: </font><a href="event:http://www.koreanrandom.com"><font color="#eb2222">Korean</font></a>' pushMessage(msg, SM_TYPE.GameGreeting) и нахрена это, когда можно обойтись меньшим кодом @ Quote Link to comment Short link Share on other sites More sharing options...
goofy67 Posted June 18, 2016 Share Posted June 18, 2016 и нахрена это, когда можно обойтись меньшим кодом Это не "лучше", просто "разные". @ 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.