Jump to content
Korean Random
Electron_i_k

Активная ссылка в Центре уведомлений WoT

Recommended Posts

Подскажите, как сделать ссылку активной, которая ведёт на внешний сайт, в клиенте WoT в центре уведомлений.

href чёт не работает.

 

Заранее спасибо.

Share this post


Link to post

Short link
Share on other sites


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 by Ekspoint
  • Upvote 3

Share this post


Link to post

Short link
Share on other sites
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

спасибо

Share this post


Link to post

Short link
Share on other sites

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)

Share this post


Link to post

Short link
Share on other sites

 

Другая возможность:

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)

и нахрена это, когда можно обойтись меньшим кодом

Share this post


Link to post

Short link
Share on other sites

и нахрена это, когда можно обойтись меньшим кодом

 

Это не "лучше", просто "разные".

Share this post


Link to post

Short link
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...