Explicit 213 Share Posted January 7, 2015 /** * Created with IntelliJ IDEA * User: Anthony * Date: 12/11/14 */ public enum OSCrosshair { /** * #ordinal corresponds with the crosshair index */ NONE, DEFAULT, ACTION } Example use: public boolean didSuccessfullyInteract() { return getMouse().getCrosshairColor() == OSCrosshair.ACTION.ordinal() } Obviously use #getLastCrosshairColor or even write another method if checking after the crosshair has disappeared. Link to comment Share on other sites More sharing options...
Eliot 193 Share Posted January 7, 2015 For those of us who may be unaware, please explain what a mouse crosshair is. Link to comment Share on other sites More sharing options...
Pandemic 2494 Share Posted January 7, 2015 For those of us who may be unaware, please explain what a mouse crosshair is. It's the little crosshair that turns red to show you clicked something. Link to comment Share on other sites More sharing options...
TheScrub 2 Share Posted January 8, 2015 enum is a waste but easier to understand then 0,1,2 Link to comment Share on other sites More sharing options...
Explicit 213 Author Share Posted January 8, 2015 enum is a waste but easier to understand then 0,1,2 No it's not, an enum makes perfect sense here. Hardcoding these values into your code is a beyond awful way to do things. Link to comment Share on other sites More sharing options...
Nuclear Nezz 2012 Share Posted January 8, 2015 No it's not, an enum makes perfect sense here. Hardcoding these values into your code is a beyond awful way to do things. But aren't you essentially hard coding it anyway with the return getMouse().getCrosshairColor() == OSCrosshair.ACTION.ordinal() ? Also we definitely have constants with the numbers for variable name recognition. I dunno if they got obfuscated or not though. Link to comment Share on other sites More sharing options...
Harold 11 Share Posted January 8, 2015 Kek the ordinals get rekt if u guys use proper obfuscation sorry m8 but probably won't work (Never use ordinal dude :-(, store it in a variable instead ) Link to comment Share on other sites More sharing options...
Explicit 213 Author Share Posted January 8, 2015 Kek the ordinals get rekt if u guys use proper obfuscation sorry m8 but probably won't work (Never use ordinal dude :-(, store it in a variable instead ) Titties, I forgot about obfuscation. But aren't you essentially hard coding it anyway with the return getMouse().getCrosshairColor() == OSCrosshair.ACTION.ordinal() ? Also we definitely have constants with the numbers for variable name recognition. I dunno if they got obfuscated or not though. How is that hard coded? If the action index changes I merely have to change the enum constant, unlike if I put the exact number in where I would have to search my code for all uses. Link to comment Share on other sites More sharing options...
Nuclear Nezz 2012 Share Posted January 10, 2015 Titties, I forgot about obfuscation. How is that hard coded? If the action index changes I merely have to change the enum constant, unlike if I put the exact number in where I would have to search my code for all uses. tru. But if you're using it in one method than you'd only have to change it in one place anyway So you have the same amount of changes. I dunno. I consider that hard coding. I wouldn't if you set variables in the enums. Or if you set it as a variable. but enum.ordinal()? I dun like it. rip Link to comment Share on other sites More sharing options...
Explicit 213 Author Share Posted January 11, 2015 tru. But if you're using it in one method than you'd only have to change it in one place anyway Where is face palm emoticon Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.