public void handle(Player player, int hash, int dyn, ExtendedOption option) { if (player.actionsBlocked()) { return; } int widgetId = Widget.getWidgetId(hash); int child = Widget.getComponentId(hash); System.out.println( "button - parent: " + widgetId + " " + ", child: " + child + ", dyn: " + dyn + ", option: " + option); // Check for correct interfaces open in the handler! WindowHandler wHandler = windowHandlers.get(widgetId); if (wHandler != null) { if (wHandler.handle(player, widgetId, child, option, dyn)) { return; } } // TODO convert all of these switched ones to the new WindowHandler switch (widgetId) { case 271: player.getPrayers().toggle(Prayer.forId(child)); break; case 387: if (child == 55) { Equipment.showEquipmentInterface(player); } break; case 771: player.getAppearance().handle(child); break; default: /* Fetch the handler list for the specified hash */ List<ButtonHandler> list = handlerLists.get(hash); /* Check if the list is valid */ if (list == null) { return; } for (ButtonHandler handler : list) { /* If the handler option is equal to the option, handle it */ if (handler.getOption() == option) { handler.handle(player, dyn); } } break; } }
public void bind(WindowHandler handler) { for (int windowId : handler.getWindowIds()) { if (windowHandlers.put(windowId, handler) != null) { System.out.println("Duplicate window handler entries for ID: " + windowId); } } }
private void doExit() { int result = JOptionPane.showConfirmDialog( this, "Do you realy what to exit?", "Exit", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null); if (result == JOptionPane.YES_OPTION) { System.exit(0); } else if (result == JOptionPane.NO_OPTION) { WindowEvent we1 = new WindowEvent( this, WindowEvent.WINDOW_STATE_CHANGED, WindowEvent.WINDOW_DEACTIVATED, WindowEvent.WINDOW_ACTIVATED); wH.windowActivated(we1); } }