from gui import InputHandler
from gui.shared.events import LoadViewEvent
from gui.shared import g_eventBus, EVENT_BUS_SCOPE
from gui.Scaleform.daapi.settings.views import VIEW_ALIAS
from helpers import isPlayerAccount

def myHandleRepeatKeyEvent(event):
    if event.key == 56:
        g_eventBus.handleEvent(LoadViewEvent(VIEW_ALIAS.LOBBY_CUSTOMIZATION), scope=EVENT_BUS_SCOPE.LOBBY)
        return True
    return False

def onAccountBecomePlayer():
    InputHandler.g_instance.onKeyDown += myHandleRepeatKeyEvent

def onAccountBecomeNonPlayer():
    InputHandler.g_instance.onKeyDown -= myHandleRepeatKeyEvent
    
from PlayerEvents import g_playerEvents
g_playerEvents.onAccountBecomePlayer += onAccountBecomePlayer
g_playerEvents.onAccountBecomeNonPlayer += onAccountBecomeNonPlayer
