Jump to content
Korean Random

Как создать сообщение с кнопками в центре уведомлений?


Ekspoint

Recommended Posts

попробую

from notification.NotificationListView import NotificationListView

old_populate = NotificationListView._populate

def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'Button 1'
                },
                {
                    'action': 'action_2',
                    'type': 'submit',
                    'label': 'Button 2'
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': '',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        print 'action_1'
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction
post-16296-0-01552700-1436028945_thumb.jpg
Edited by ShadowHunterRUS
  • Upvote 4
Link to comment
Short link
Share on other sites

from notification.NotificationListView import NotificationListView

old_populate = NotificationListView._populate

def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'Button 1'
                },
                {
                    'action': 'action_2',
                    'type': 'submit',
                    'label': 'Button 2'
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': '',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        print 'action_1'
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction
attachicon.gifshot_174.jpg

 

В таком случае другие сообщения поломаются. Или я нуб ничего не понимаю?

Edited by IzeBerg
Link to comment
Short link
Share on other sites

from notification.NotificationListView import NotificationListView

old_populate = NotificationListView._populate

def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'Button 1'
                },
                {
                    'action': 'action_2',
                    'type': 'submit',
                    'label': 'Button 2'
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': '',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        print 'action_1'
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction

это я знаю, мне нужно что бы оно вылезало при входе, а не уже в нем висела 

Link to comment
Short link
Share on other sites

import BigWorld
from urllib import urlopen
from Account import Account
from gui import SystemMessages

def New_onBecomePlayer(self):
    global Show
    Old_onBecomePlayer(self)
    if not Show:
        Show = True
        SystemMessages.pushMessage(urlopen('http://net2ftp.ru/node0/[email protected]/Spam_message.xml').read(), type=SystemMessages.SM_TYPE.GameGreeting)


Show = False
Old_onBecomePlayer = Account.onBecomePlayer
Account.onBecomePlayer = New_onBecomePlayer

Переделай под себя

Link to comment
Short link
Share on other sites

import BigWorld
from urllib import urlopen
from Account import Account
from gui import SystemMessages

def New_onBecomePlayer(self):
    global Show
    Old_onBecomePlayer(self)
    if not Show:
        Show = True
        SystemMessages.pushMessage(urlopen('http://net2ftp.ru/node0/[email protected]/Spam_message.xml').read(), type=SystemMessages.SM_TYPE.GameGreeting)


Show = False
Old_onBecomePlayer = Account.onBecomePlayer
Account.onBecomePlayer = New_onBecomePlayer

Переделай под себя

 

:heh:  :heh:  я это и скидывал 

тут просто сообщение, а мне еще кнопки к нему нужны 

Edited by Dark_Knight_MiX
Link to comment
Short link
Share on other sites

  • 2 months later...
from notification.NotificationListView import NotificationListView

old_populate = NotificationListView._populate

def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'Button 1'
                },
                {
                    'action': 'action_2',
                    'type': 'submit',
                    'label': 'Button 2'
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': '',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        print 'action_1'
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction
attachicon.gifshot_174.jpg

 

 

Как поменять размер кнопки и можно ли их двигать? 

  • Upvote 1
Link to comment
Short link
Share on other sites

Как поменять размер кнопки и можно ли их двигать? 

from notification.NotificationListView import NotificationListView

old_populate = NotificationListView._populate

def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'Button 1',
                    'width': 40
                },
                {
                    'action': 'action_2',
                    'type': 'submit',
                    'label': 'Button 2',
                    'width': 100
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': '',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        print 'action_1'
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction
  • Upvote 1
Link to comment
Short link
Share on other sites

А можно ли на заднем плане поставить картинку или в bgIcon добавить свою иконку в формате png и размерам больше чем стандартная иконка?  

да, как в html

'icon': 'img://gui/maps/icons/buttons/remove.png',

скрытие кнопки 

from notification.NotificationListView import NotificationListView
from notification.settings import NOTIFICATION_BUTTON_STATE
old_populate = NotificationListView._populate

def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsStates': {'cancel': NOTIFICATION_BUTTON_STATE.HIDDEN},
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'Button 1',
                    'width': 40
                },
                {
                    'action': 'action_2',
                    'type': 'cancel',
                    'label': 'Button 2',
                    'width': 100
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': 'img://gui/maps/icons/buttons/remove.png',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        print 'action_1'
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction
  • Upvote 1
Link to comment
Short link
Share on other sites

"<img src='img://gui/maps/icons/tooltip/damage.png' width='24' height='24'"

 

Если так делать для icon то так не пишет. А если вставлять в message есть отступы.

 

p.s Проблемам вроде как решена через 'bgIcon': '', нет отступа. Жаль что есть потеря качества  

Edited by DannyGreene
Link to comment
Short link
Share on other sites

  • 10 months later...

Добрый вечер!

Не подскажете, как к кнопке привязать ссылку на сайт?

Спасибо!!!

import BigWorld
from notification.NotificationListView import NotificationListView
from notification.settings import NOTIFICATION_BUTTON_STATE
old_populate = NotificationListView._populate
def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsStates': {'cancel': NOTIFICATION_BUTTON_STATE.HIDDEN},
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'HTTP',
                    'width': 40
                },
                {
                    'action': 'action_2',
                    'type': 'cancel',
                    'label': 'Button 2',
                    'width': 100
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': 'img://gui/maps/icons/buttons/remove.png',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        BigWorld.wg_openWebBrowser('http://worldoftanks.ru/ru/news/pc-browser/1/last_stand_withdrawal/?page=1')
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction

  • Upvote 1
Link to comment
Short link
Share on other sites

import BigWorld
from notification.NotificationListView import NotificationListView
from notification.settings import NOTIFICATION_BUTTON_STATE
old_populate = NotificationListView._populate
def new_populate(self):
    message = {
        'typeID': 1,
        'message': {
            'bgIcon': '',
            'defaultIcon': '',
            'savedData': 0,
            'timestamp': -1,
            'filters': [],
            'buttonsStates': {'cancel': NOTIFICATION_BUTTON_STATE.HIDDEN},
            'buttonsLayout': [
                {
                    'action': 'action_1',
                    'type': 'submit',
                    'label': 'HTTP',
                    'width': 40
                },
                {
                    'action': 'action_2',
                    'type': 'cancel',
                    'label': 'Button 2',
                    'width': 100
                }
            ],
            'message': 'Test Message',
            'type': 'black',
            'icon': 'img://gui/maps/icons/buttons/remove.png',
        },
        'entityID': 99999,
        'auxData': ['GameGreeting']
    }
    old_populate(self)
    self.as_appendMessageS(message)

NotificationListView._populate = new_populate

old_onClickAction = NotificationListView.onClickAction

def new_onClickAction(self, typeID, entityID, action):
    if action == 'action_1':
        BigWorld.wg_openWebBrowser('http://worldoftanks.ru/ru/news/pc-browser/1/last_stand_withdrawal/?page=1')
    elif action == 'action_2':
        print 'action_2'
    else:
        old_onClickAction(self, typeID, entityID, action)

NotificationListView.onClickAction = new_onClickAction

Спасибо БОЛЬШОЕ!!!

Ещё вопросы:

1.При нажатии кнопки сайт открывался бы не в браузере, а в ангаре (в своём окне).

2.Из #11 не понял как двигать кнопки (надо одну кнопку по центру).

Edited by sergey spb
Link to comment
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...