Small Progress on the Gui Animation System

This commit is contained in:
Speiger 2024-06-02 14:25:20 +02:00
parent 099eec4fe4
commit 36ce0209fb
3 changed files with 23 additions and 12 deletions

View File

@ -45,6 +45,7 @@ public class GuiAnimation {
public GuiAnimation build() {
float duration = 0F;
actions.values().mapToFloat(IAction::duration).reduce(Math::max);
for(IAction action : actions.values()) {
duration = Math.max(duration, action.duration());
}

View File

@ -0,0 +1,5 @@
package speiger.src.coreengine.rendering.gui.animation;
public class GuiAnimator {
}

View File

@ -1,28 +1,33 @@
package speiger.src.coreengine.rendering.input.events;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Iterator;
import speiger.src.collections.objects.utils.ObjectIterators;
public class FileEvents {
public static class Drop extends MouseEvent {
Path[] files;
String[] extension;
String[] name;
public static class Drop extends MouseEvent implements Iterable<DroppedFile> {
DroppedFile[] files;
public Drop(long window, int x, int y, Path[] files) {
super(window, x, y);
this.files = files;
this.extension = new String[files.length];
this.name = new String[files.length];
this.files = new DroppedFile[files.length];
for(int i = 0,m=files.length;i<m;i++) {
String name = files[i].getFileName().toString();
this.name[i] = name;
this.extension[i] = name.substring(name.lastIndexOf(".")+1);
this.files[i] = new DroppedFile(files[i], name, name.substring(name.lastIndexOf(".")+1));
}
}
@Override
public Iterator<DroppedFile> iterator() { return ObjectIterators.wrap(files); }
public int size() { return files.length; }
public Path file(int index) { return files[index]; }
public String extension(int index) { return extension[index]; }
public String name(int index) { return name[index]; }
public DroppedFile get() { return files[0]; }
public DroppedFile get(int index) { return files[index]; }
}
public record DroppedFile(Path path, String name, String extension) {
public boolean isFolder() { return Files.isDirectory(path); }
public boolean isFile() { return Files.isRegularFile(path); }
}
}