RetroBot 35 Share Posted June 28, 2017 Made this snippet to check if there was an interface up before doing an action, and thought this could be of some use to some people. private final int CLOSE_TEXTURE_ID = 535; public boolean isRandomInterfaceOpen() { for (Widget parent : getWidgets().getWidgets()) { for (WidgetChild child : parent.getChildren()) { if (child.getTextureId() == CLOSE_TEXTURE_ID) { return true; } for (WidgetChild grandchild : child.getChildren()) { if (grandchild.getTextureId() == CLOSE_TEXTURE_ID) { return true; } } } } return false; } Link to comment Share on other sites More sharing options...
Hashtag 8707 Share Posted June 28, 2017 Might be useful, thanks =). Link to comment Share on other sites More sharing options...
Polymorphism 48 Share Posted June 28, 2017 I wonder if it would be less intensive to filter non visible widgets and their children prior to iteration. Otherwise good snippet! Link to comment Share on other sites More sharing options...
None 227 Share Posted June 28, 2017 I wonder if it would be less intensive to filter non visible widgets and their children prior to iteration. Otherwise good snippet! final static int CLOSE_TEXTURE_ID = 535; List<WidgetChild> randomInterface = new ArrayList<WidgetChild>(); public boolean isRandomInterfaceOpen() { randomInterface = getWidgets().getWidgets(f -> f !=null && f.isVisible() && (f.isGrandChild() && f.getTextureId() == CLOSE_TEXTURE_ID || f.getChildTextureID() == CLOSE_TEXTURE_ID)); return randomInterface !=null && !randomInterface.isEmpty(); } Link to comment Share on other sites More sharing options...
Polymorphism 48 Share Posted June 28, 2017 final static int CLOSE_TEXTURE_ID = 535; List<WidgetChild> randomInterface = new ArrayList<WidgetChild>(); public boolean isRandomInterfaceOpen() { randomInterface = getWidgets().getWidgets(f -> f !=null && f.isVisible() && (f.isGrandChild() && f.getTextureId() == CLOSE_TEXTURE_ID || f.getChildTextureID() == CLOSE_TEXTURE_ID)); return randomInterface !=null && !randomInterface.isEmpty(); } Yes, was hoping he'd change his code tho. Link to comment Share on other sites More sharing options...
Volta 183 Share Posted June 28, 2017 Oo thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.