@Override public void onFrameAdd(final FrameHandler frameHandler, final boolean isAboutToBeAdded) { if (!isAboutToBeAdded) { this.m_dialogUnloadListener = new DialogUnloadListener() { @Override public void dialogUnloaded(final String id) { if (id.equals("moderatorChatDialog")) { UIModeratorChatFrame.this.askToCloseRequest(); } } }; Xulor.getInstance().addDialogUnloadListener(this.m_dialogUnloadListener); Xulor.getInstance() .load( "moderatorChatDialog", Dialogs.getDialogPath("moderatorChatDialog"), 40977L, (short) 10000); Xulor.getInstance().putActionClass("wakfu.moderatorChat", ModeratorChatDialogActions.class); final Message msg = new UIChatCreationRequestMessage( (short) 19067, this.m_remoteUser, new Listener(this.m_firstMessage, this.m_sourceId, this.m_remoteUser)); Worker.getInstance().pushMessage(msg); this.m_isRunning = true; } }
@Override public void onFrameRemove(final FrameHandler frameHandler, final boolean isAboutToBeRemoved) { if (!isAboutToBeRemoved) { Xulor.getInstance().removeDialogUnloadListener(this.m_dialogUnloadListener); UIChatFrameHelper.closeModeratorChatWindow(); Xulor.getInstance().unload("moderatorChatDialog"); Xulor.getInstance().removeActionClass("wakfu.moderatorChat"); if (this.m_isRunning) { final Message notifyToOtherSide = new CloseModeratorRequestMessage(); WakfuGameEntity.getInstance().getNetworkEntity().sendMessage(notifyToOtherSide); this.m_isRunning = false; } } }
private void askToCloseRequest() { if (this.m_isRunning) { final MessageBoxData data = new MessageBoxData( 102, 0, WakfuTranslator.getInstance().getString("contactModerator.suretoclose"), 24L); final MessageBoxControler controler = Xulor.getInstance().msgBox(data); controler.addEventListener( new MessageBoxEventListener() { @Override public void messageBoxClosed(final int type, final String userEntry) { if (type == 8) { WakfuGameEntity.getInstance().removeFrame(UIModeratorChatFrame.this); } } }); } else { WakfuGameEntity.getInstance().removeFrame(this); } }