FrozenWolf wrote: Sat Jan 16, 2021 9:21 pm
GodDragon wrote: Sat Jan 16, 2021 7:59 pm
Thanks! I changed the media show image function a bit so it won't be shown twice but keeps the cooldown in seconds (if given). Because in your case it wouldn't account for an integer as a second argument anymore if a string was given.
Ah, good catch, I didn't spot that!
I'm currently experimenting with refactoring the showImage handling to reduce the complexity by using reflection. That means that all of the parameter matching and error reporting relating to mismatched parameters is done in the CustomFunction base class, and the derived class just has to provide functions to match the desired parameters. I'll push it to a branch in my fork at some point and give you a link to the changes just to see what you think. I'm about to soak test it with an actual session with Michaela Isizzu , so either my code will break, or Michaela will break me.
Michaela broke me; anyway, have a look at this to see what you think:
This is what ShowImageFunction.java looks like now (it should work the same as before):
https://github.com/FrozenWolf4887/Tease ... ction.java
This is the supporting CustomFunctionExtended.java:
https://github.com/FrozenWolf4887/Tease ... ended.java
CustomFunctionExtended is derived from CustomFunction to incorporate the new feature without breaking all of the existing function implementations. That would mean that if you'd like to incorporate that technique into the other functions, it can be done one at a time, and when they're all done, we can merge CustomFunctionExtended and CustomFunction together.
All that the derived class has to do is have protected methods with the name "handleCall" and whatever parameters they need, and the base class will handle the gritty details. It still needs a bit of polishing, I've already spotted two bugs from just writing this post.
Did some basic testing with the following little script:
Code: Select all
let file1 = showImage("Images/Spicy/Deck/1/C1.jpg");
sleep(5);
let file2 = showImage("Images/Spicy/Deck/1/D1.jpg", 5);
showImage(file1);
sleep(5);
showImage(file2, 5);
// deliberately bad calls
showImage();
showImage(8);
showImage(9, file1);
showImage(file1, 6, 7);
The first four calls to showImage work fine, and the latter four produce the following log output:
Code: Select all
10:48:12 pm SEVERE: No match for function call to showImage()
10:48:12 pm INFO: Candidate functions are:
10:48:12 pm INFO: showImage(MediaURL)
10:48:12 pm INFO: showImage(File, Integer)
10:48:12 pm INFO: showImage(MediaURL, Integer)
10:48:12 pm INFO: showImage(File)
10:48:12 pm INFO: showImage(String, Integer)
10:48:12 pm INFO: showImage(String)
10:48:12 pm SEVERE: No match for function call to showImage(Integer)
10:48:12 pm INFO: Candidate functions are:
10:48:12 pm INFO: showImage(MediaURL)
10:48:12 pm INFO: showImage(File, Integer)
10:48:12 pm INFO: showImage(MediaURL, Integer)
10:48:12 pm INFO: showImage(File)
10:48:12 pm INFO: showImage(String, Integer)
10:48:12 pm INFO: showImage(String)
10:48:12 pm SEVERE: No match for function call to showImage(Integer, File)
10:48:12 pm INFO: Candidate functions are:
10:48:12 pm INFO: showImage(MediaURL)
10:48:12 pm INFO: showImage(File, Integer)
10:48:12 pm INFO: showImage(MediaURL, Integer)
10:48:12 pm INFO: showImage(File)
10:48:12 pm INFO: showImage(String, Integer)
10:48:12 pm INFO: showImage(String)
10:48:12 pm SEVERE: No match for function call to showImage(File, Integer, Integer)
10:48:12 pm INFO: Candidate functions are:
10:48:12 pm INFO: showImage(MediaURL)
10:48:12 pm INFO: showImage(File, Integer)
10:48:12 pm INFO: showImage(MediaURL, Integer)
10:48:12 pm INFO: showImage(File)
10:48:12 pm INFO: showImage(String, Integer)
10:48:12 pm INFO: showImage(String)