blob: 240c97d112bfa3b5070563a4d04336f65b019e6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package io.polyfrost.oneconfig.themes;
import io.polyfrost.oneconfig.OneConfig;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class Themes {
public static final int VERSION = 0;
public static Theme activeTheme;
public static final Logger themeLog = LogManager.getLogger("OneConfig Themes");
/**
* Return a list of all available themes in the directory.
* @return list of themes
*/
public static List<File> getThemes() {
FilenameFilter filter = (dir, name) -> name.endsWith(".zip");
return Arrays.asList(Objects.requireNonNull(OneConfig.themesDir.listFiles(filter)));
}
/**
* Return the active theme instance.
*/
public static Theme getActiveTheme() {
return activeTheme;
}
/**
* Open a new theme in the window, and restart the GUI.
* @param theme Theme file to open
*/
public static void openTheme(File theme) {
try {
activeTheme = new Theme(theme);
} catch (IOException e) {
e.printStackTrace();
}
// TODO restart gui
}
public String toString() {
return "OneConfig Theme {loaded=" + activeTheme.getLoadedTime() + ", name=" + activeTheme.getName() + ", desc=" + activeTheme.getDescription() + ", ready=" + activeTheme.isReady() + "}";
}
}
|