List of usage examples for java.awt.geom Rectangle2D.Float contains
public boolean contains(double x, double y)
From source file:me.timothy.ddd.conversation.Conversation.java
public boolean onClick(int x, int y) { EntityConversationInfo convInfo = entity.getEntityInfo().getConversation(); List<EntityConversationInfo.ConversationMessage> messages = convInfo.getText(); if (messages.size() <= index) { if (convInfo.getQuest() != null) { questManager.convoEnded(entity, convInfo.getQuest(), choiceTree); }//w w w.j ava2 s.c o m text = null; return false; } EntityConversationInfo.ConversationMessage currentMessage = messages.get(index); if (currentChoices == null) { logger.info("Conversation continued.."); text = currentMessage.getMsg(); text = DDDUtils.addNewlines(text, 45); currentChoices = currentMessage.getChoices(); createButtons(); if (choiceTree == null) { choiceTree = new int[messages.size()]; } if (currentChoices == null) { if (currentMessage.getJumpTo() != EntityConversationInfo.NO_JUMP_TO) { index = currentMessage.getJumpTo(); } else if (!currentMessage.isEnd()) index++; else index = Integer.MAX_VALUE; } } else { int choice = -1; for (int i = 0; i < currentChoices.size(); i++) { Rectangle2D.Float rect = buttonLocations.get(i); if (rect.contains(x, y)) { choice = i; break; } } if (choice == -1) { return true; } choiceTree[counter++] = choice; ConversationChoice choiceObj = currentChoices.get(choice); boolean finished = choiceObj.isEnd() || choiceObj.getJumpTo() == EntityConversationInfo.NO_JUMP_TO; if (finished) { if (convInfo.getQuest() != null) { questManager.convoEnded(entity, convInfo.getQuest(), choiceTree); } text = null; return false; } int newIndex = choiceObj.getJumpTo(); index = newIndex; currentMessage = messages.get(index); text = currentMessage.getMsg(); text = DDDUtils.addNewlines(text, 45); currentChoices = currentMessage.getChoices(); createButtons(); if (currentChoices == null) { if (currentMessage.isEnd()) { index = Integer.MAX_VALUE; } else { index++; } } logger.printf(Level.INFO, "Chose choice %d which jumped up to index %d", choice, newIndex); } return true; }