Skip to content

Commit

Permalink
Improve frame string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
RoanH committed Aug 15, 2020
1 parent 6cc13dc commit cecd209
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion osuSkinChecker/src/me/roan/osuskinchecker/ImageFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,19 @@ public boolean isAnimated(){
*/
public String getFrameString(){
int[] nums = matches.stream().mapToInt(ImageMeta::getSequenceNumber).filter(i->i >= 0).distinct().sorted().toArray();
if(nums.length == 1){
return "frame " + nums[0];
}
StringJoiner buffer = new StringJoiner(", ");
int start = nums[0];
int last = nums[0];
for(int i = 1; i < nums.length; i++){
if(nums[i] != last + 1){
buffer.add(start + "-" + last);
if(start == last){
buffer.add(String.valueOf(start));
}else{
buffer.add(start + "-" + last);
}
start = nums[i];
}
last = nums[i];
Expand Down

0 comments on commit cecd209

Please sign in to comment.