diff --git a/src/main/java/com/group_finity/mascot/ui/debug/DebugUi.java b/src/main/java/com/group_finity/mascot/DebugUi.java similarity index 67% rename from src/main/java/com/group_finity/mascot/ui/debug/DebugUi.java rename to src/main/java/com/group_finity/mascot/DebugUi.java index a7c822e..1bae51c 100644 --- a/src/main/java/com/group_finity/mascot/ui/debug/DebugUi.java +++ b/src/main/java/com/group_finity/mascot/DebugUi.java @@ -1,6 +1,4 @@ -package com.group_finity.mascot.ui.debug; - -import com.group_finity.mascot.Mascot; +package com.group_finity.mascot; public interface DebugUi { diff --git a/src/main/java/com/group_finity/mascot/Mascot.java b/src/main/java/com/group_finity/mascot/Mascot.java index 03d92fc..3fe7cd2 100644 --- a/src/main/java/com/group_finity/mascot/Mascot.java +++ b/src/main/java/com/group_finity/mascot/Mascot.java @@ -7,9 +7,9 @@ import com.group_finity.mascot.image.MascotImage; import com.group_finity.mascot.imageset.ImageSet; import com.group_finity.mascot.imageset.ImageSetStore; -import com.group_finity.mascot.ui.debug.DebugUi; -import com.group_finity.mascot.ui.debug.DebugWindow; import com.group_finity.mascot.window.TranslucentWindow; +// todo: not ok +import com.group_finity.mascotapp.gui.debug.DebugWindow; import javax.sound.sampled.Clip; import java.awt.Point; @@ -80,6 +80,7 @@ public Mascot(final String imageSet, MascotPrefProvider prefProvider, ImageSetSt void startDebugUi() { if (debugUi == null) { + // todo: maybe make this a factory debugUi = new DebugWindow(); } // slightly messy diff --git a/src/main/java/com/group_finity/mascot/MascotEventHandler.java b/src/main/java/com/group_finity/mascot/MascotEventHandler.java index 5e198a5..abe313e 100644 --- a/src/main/java/com/group_finity/mascot/MascotEventHandler.java +++ b/src/main/java/com/group_finity/mascot/MascotEventHandler.java @@ -2,9 +2,9 @@ import com.group_finity.mascot.behavior.Behavior; import com.group_finity.mascot.exception.CantBeAliveException; -import com.group_finity.mascot.ui.contextmenu.MenuItemRep; -import com.group_finity.mascot.ui.contextmenu.MenuRep; -import com.group_finity.mascot.ui.contextmenu.TopLevelMenuRep; +import com.group_finity.mascot.window.contextmenu.MenuItemRep; +import com.group_finity.mascot.window.contextmenu.MenuRep; +import com.group_finity.mascot.window.contextmenu.TopLevelMenuRep; import com.group_finity.mascot.window.TranslucentWindowEvent; import com.group_finity.mascot.window.TranslucentWindowEventHandler; diff --git a/src/main/java/com/group_finity/mascot/window/TranslucentWindowEventHandler.java b/src/main/java/com/group_finity/mascot/window/TranslucentWindowEventHandler.java index f1453d7..f894d9f 100644 --- a/src/main/java/com/group_finity/mascot/window/TranslucentWindowEventHandler.java +++ b/src/main/java/com/group_finity/mascot/window/TranslucentWindowEventHandler.java @@ -1,6 +1,6 @@ package com.group_finity.mascot.window; -import com.group_finity.mascot.ui.contextmenu.TopLevelMenuRep; +import com.group_finity.mascot.window.contextmenu.TopLevelMenuRep; public interface TranslucentWindowEventHandler { diff --git a/src/main/java/com/group_finity/mascot/ui/contextmenu/MenuItemRep.java b/src/main/java/com/group_finity/mascot/window/contextmenu/MenuItemRep.java similarity index 94% rename from src/main/java/com/group_finity/mascot/ui/contextmenu/MenuItemRep.java rename to src/main/java/com/group_finity/mascot/window/contextmenu/MenuItemRep.java index f1daaf7..7422ecb 100644 --- a/src/main/java/com/group_finity/mascot/ui/contextmenu/MenuItemRep.java +++ b/src/main/java/com/group_finity/mascot/window/contextmenu/MenuItemRep.java @@ -1,4 +1,4 @@ -package com.group_finity.mascot.ui.contextmenu; +package com.group_finity.mascot.window.contextmenu; public class MenuItemRep { diff --git a/src/main/java/com/group_finity/mascot/ui/contextmenu/MenuRep.java b/src/main/java/com/group_finity/mascot/window/contextmenu/MenuRep.java similarity index 84% rename from src/main/java/com/group_finity/mascot/ui/contextmenu/MenuRep.java rename to src/main/java/com/group_finity/mascot/window/contextmenu/MenuRep.java index 6855068..577a5fc 100644 --- a/src/main/java/com/group_finity/mascot/ui/contextmenu/MenuRep.java +++ b/src/main/java/com/group_finity/mascot/window/contextmenu/MenuRep.java @@ -1,4 +1,4 @@ -package com.group_finity.mascot.ui.contextmenu; +package com.group_finity.mascot.window.contextmenu; public class MenuRep extends MenuItemRep { diff --git a/src/main/java/com/group_finity/mascot/ui/contextmenu/TopLevelMenuRep.java b/src/main/java/com/group_finity/mascot/window/contextmenu/TopLevelMenuRep.java similarity index 91% rename from src/main/java/com/group_finity/mascot/ui/contextmenu/TopLevelMenuRep.java rename to src/main/java/com/group_finity/mascot/window/contextmenu/TopLevelMenuRep.java index 885ef51..3df8c93 100644 --- a/src/main/java/com/group_finity/mascot/ui/contextmenu/TopLevelMenuRep.java +++ b/src/main/java/com/group_finity/mascot/window/contextmenu/TopLevelMenuRep.java @@ -1,4 +1,4 @@ -package com.group_finity.mascot.ui.contextmenu; +package com.group_finity.mascot.window.contextmenu; public class TopLevelMenuRep extends MenuRep { diff --git a/src/main/java/com/group_finity/mascotapp/Manager.java b/src/main/java/com/group_finity/mascotapp/Manager.java index 38706ad..bb63f69 100644 --- a/src/main/java/com/group_finity/mascotapp/Manager.java +++ b/src/main/java/com/group_finity/mascotapp/Manager.java @@ -12,6 +12,9 @@ public class Manager implements MascotManager { + // this could technically go in mascot since it does draw the mascots (maybe as DefaultManager?) + // todo: think abt it later + public static final int TICK_INTERVAL_MILLIS = 40; private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); @@ -53,7 +56,7 @@ private void runPendingTasks() { } // basically just that linkedHashSet thing from the original Manager - void queueTask(Runnable r) { + public void queueTask(Runnable r) { tasks.add(r); } diff --git a/src/main/java/com/group_finity/mascotapp/ShimejiEE.java b/src/main/java/com/group_finity/mascotapp/ShimejiEE.java index 0bbed26..d03e87b 100644 --- a/src/main/java/com/group_finity/mascotapp/ShimejiEE.java +++ b/src/main/java/com/group_finity/mascotapp/ShimejiEE.java @@ -1,12 +1,9 @@ package com.group_finity.mascotapp; +import com.group_finity.mascotapp.runners.MinimalRunner; import picocli.CommandLine; import picocli.CommandLine.Command; -import javax.swing.*; - -import static picocli.CommandLine.*; - @Command(name = "shimeji", version = "2.1.0", mixinStandardHelpOptions = true, description = "%nShimejiEE desktop pets%nrun jar with no args for default configuration%n" ) @@ -14,7 +11,7 @@ public class ShimejiEE { public static void main(String[] args) { var ec = new CommandLine(new ShimejiEE()) - .addSubcommand("run", new ShimejiRun()) + .addSubcommand("run", new MinimalRunner()) .execute("run"); } } diff --git a/src/main/java/com/group_finity/mascot/ui/Theme.java b/src/main/java/com/group_finity/mascotapp/gui/Theme.java similarity index 90% rename from src/main/java/com/group_finity/mascot/ui/Theme.java rename to src/main/java/com/group_finity/mascotapp/gui/Theme.java index 7e5e464..ded2c51 100644 --- a/src/main/java/com/group_finity/mascot/ui/Theme.java +++ b/src/main/java/com/group_finity/mascotapp/gui/Theme.java @@ -1,4 +1,4 @@ -package com.group_finity.mascot.ui; +package com.group_finity.mascotapp.gui; import java.awt.Color; diff --git a/src/main/java/com/group_finity/mascot/ui/imagesets/CompactChooser.java b/src/main/java/com/group_finity/mascotapp/gui/chooser/CompactChooser.java similarity index 98% rename from src/main/java/com/group_finity/mascot/ui/imagesets/CompactChooser.java rename to src/main/java/com/group_finity/mascotapp/gui/chooser/CompactChooser.java index bd8fce6..f01322a 100644 --- a/src/main/java/com/group_finity/mascot/ui/imagesets/CompactChooser.java +++ b/src/main/java/com/group_finity/mascotapp/gui/chooser/CompactChooser.java @@ -1,8 +1,8 @@ -package com.group_finity.mascot.ui.imagesets; +package com.group_finity.mascotapp.gui.chooser; import com.group_finity.mascot.Tr; import com.group_finity.mascot.imageset.ShimejiProgramFolder; -import com.group_finity.mascot.ui.Theme; +import com.group_finity.mascotapp.gui.Theme; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; diff --git a/src/main/java/com/group_finity/mascot/ui/imagesets/CompactImageSetList.java b/src/main/java/com/group_finity/mascotapp/gui/chooser/CompactImageSetList.java similarity index 94% rename from src/main/java/com/group_finity/mascot/ui/imagesets/CompactImageSetList.java rename to src/main/java/com/group_finity/mascotapp/gui/chooser/CompactImageSetList.java index 35cf49d..750b97a 100644 --- a/src/main/java/com/group_finity/mascot/ui/imagesets/CompactImageSetList.java +++ b/src/main/java/com/group_finity/mascotapp/gui/chooser/CompactImageSetList.java @@ -1,6 +1,6 @@ -package com.group_finity.mascot.ui.imagesets; +package com.group_finity.mascotapp.gui.chooser; -import com.group_finity.mascot.ui.Theme; +import com.group_finity.mascotapp.gui.Theme; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; diff --git a/src/main/java/com/group_finity/mascot/ui/imagesets/CompactImageSetPreview.java b/src/main/java/com/group_finity/mascotapp/gui/chooser/CompactImageSetPreview.java similarity index 98% rename from src/main/java/com/group_finity/mascot/ui/imagesets/CompactImageSetPreview.java rename to src/main/java/com/group_finity/mascotapp/gui/chooser/CompactImageSetPreview.java index 71c17b2..12f4df4 100644 --- a/src/main/java/com/group_finity/mascot/ui/imagesets/CompactImageSetPreview.java +++ b/src/main/java/com/group_finity/mascotapp/gui/chooser/CompactImageSetPreview.java @@ -1,4 +1,4 @@ -package com.group_finity.mascot.ui.imagesets; +package com.group_finity.mascotapp.gui.chooser; import javax.imageio.ImageIO; import javax.swing.Box; diff --git a/src/main/java/com/group_finity/mascot/ui/imagesets/ImageSetChooserUtils.java b/src/main/java/com/group_finity/mascotapp/gui/chooser/ImageSetChooserUtils.java similarity index 93% rename from src/main/java/com/group_finity/mascot/ui/imagesets/ImageSetChooserUtils.java rename to src/main/java/com/group_finity/mascotapp/gui/chooser/ImageSetChooserUtils.java index e5c277a..97f636d 100644 --- a/src/main/java/com/group_finity/mascot/ui/imagesets/ImageSetChooserUtils.java +++ b/src/main/java/com/group_finity/mascotapp/gui/chooser/ImageSetChooserUtils.java @@ -1,4 +1,4 @@ -package com.group_finity.mascot.ui.imagesets; +package com.group_finity.mascotapp.gui.chooser; import com.group_finity.mascot.imageset.ShimejiProgramFolder; diff --git a/src/main/java/com/group_finity/mascot/ui/debug/DebugWindow.java b/src/main/java/com/group_finity/mascotapp/gui/debug/DebugWindow.java similarity index 99% rename from src/main/java/com/group_finity/mascot/ui/debug/DebugWindow.java rename to src/main/java/com/group_finity/mascotapp/gui/debug/DebugWindow.java index d2140a2..3ba795c 100644 --- a/src/main/java/com/group_finity/mascot/ui/debug/DebugWindow.java +++ b/src/main/java/com/group_finity/mascotapp/gui/debug/DebugWindow.java @@ -1,5 +1,6 @@ -package com.group_finity.mascot.ui.debug; +package com.group_finity.mascotapp.gui.debug; +import com.group_finity.mascot.DebugUi; import com.group_finity.mascot.Mascot; import com.group_finity.mascot.Tr; import com.group_finity.mascot.environment.Area; diff --git a/src/main/java/com/group_finity/mascotapp/imageset/ImageSetManager.java b/src/main/java/com/group_finity/mascotapp/imageset/ImageSetManager.java index e3d6dbb..ef658c4 100644 --- a/src/main/java/com/group_finity/mascotapp/imageset/ImageSetManager.java +++ b/src/main/java/com/group_finity/mascotapp/imageset/ImageSetManager.java @@ -28,7 +28,7 @@ public void setSelected(Collection newSelected) { // get list copy first so we're not deleting while iterating getLoaded().stream() .filter(s -> !newSelected.contains(s)) - .forEach(this::removeSelected); + .forEach(this::removeImageSet); for (String s : newSelected) { if (!loaded.containsKey(s)) { @@ -43,8 +43,11 @@ public void setSelected(Collection newSelected) { } } - private void removeSelected(String name) { + private void removeImageSet(String name) { var ims = loaded.get(name); + if (ims == null) { + return; + } selectionDelegate.imageSetWillBeRemoved(name, ims); selected.remove(name); loaded.remove(name); @@ -93,4 +96,11 @@ public Collection getSelected() { public Collection getLoaded() { return loaded.keySet().stream().toList(); } + + public String getRandomSelection() { + return selected.stream() + .skip(new Random().nextInt(selected.size())) + .findFirst() + .orElse(null); + } } diff --git a/src/main/java/com/group_finity/mascotapp/ShimejiRun.java b/src/main/java/com/group_finity/mascotapp/runners/MinimalRunner.java similarity index 75% rename from src/main/java/com/group_finity/mascotapp/ShimejiRun.java rename to src/main/java/com/group_finity/mascotapp/runners/MinimalRunner.java index 305a327..708edf5 100644 --- a/src/main/java/com/group_finity/mascotapp/ShimejiRun.java +++ b/src/main/java/com/group_finity/mascotapp/runners/MinimalRunner.java @@ -1,4 +1,4 @@ -package com.group_finity.mascotapp; +package com.group_finity.mascotapp.runners; import com.group_finity.mascot.Mascot; import com.group_finity.mascot.NativeFactory; @@ -12,23 +12,22 @@ import com.group_finity.mascot.imageset.ShimejiImageSet; import com.group_finity.mascot.imageset.ShimejiProgramFolder; import com.group_finity.mascot.sound.SoundLoader; +import com.group_finity.mascotapp.Constants; +import com.group_finity.mascotapp.Manager; import com.group_finity.mascotapp.imageset.ImageSetLoadingDelegate; import com.group_finity.mascotapp.imageset.ImageSetManager; import com.group_finity.mascotapp.imageset.ImageSetSelectionDelegate; -import com.group_finity.mascotapp.options.*; +import com.group_finity.mascotapp.options.ImageSetOptions; +import com.group_finity.mascotapp.options.LaunchAppOptions; +import com.group_finity.mascotapp.options.PersistentAppOptions; +import com.group_finity.mascotapp.options.ProgramFolderOptions; import javax.xml.parsers.DocumentBuilderFactory; -import java.awt.*; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; +import java.awt.Point; import java.nio.file.Path; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; import java.util.logging.LogManager; -import static java.util.Map.*; import static picocli.CommandLine.*; @Command( @@ -39,7 +38,7 @@ sortOptions = false, sortSynopsis = false ) -public class ShimejiRun implements Callable, ImageSetLoadingDelegate, ImageSetSelectionDelegate { +public class MinimalRunner implements Runnable, ImageSetLoadingDelegate, ImageSetSelectionDelegate { // saved @ArgGroup(validate = false, heading = "%nGeneral:%n") PersistentAppOptions genOpts = new PersistentAppOptions(); @@ -49,17 +48,13 @@ public class ShimejiRun implements Callable, ImageSetLoadingDelegate, I @ArgGroup(validate = false, heading = "%nProgram Folder:%n") ProgramFolderOptions pfOpts = new ProgramFolderOptions(); @ArgGroup(validate = false, heading = "%nLaunch:%n") LaunchAppOptions launchOpts = new LaunchAppOptions(); - private Manager manager = new Manager(); - private ImageSetManager imageSets = new ImageSetManager(this, this); + private Manager manager; + private ImageSetManager imageSets; private ShimejiProgramFolder programFolder = null; @Override public ImageSet load(String name) { - if (programFolder == null) { - programFolder = pfOpts.toProgramFolder(Constants.JAR_DIR); - } - try { return loadImageSet(programFolder, name, imgOpts); } catch (Exception e) { @@ -88,7 +83,16 @@ public void imageSetHasBeenRemoved(String name, ImageSet imageSet) { @Override public void imageSetHasBeenAdded(String name, ImageSet imageSet) { - var m = new Mascot(name, imgOpts, imageSets); + spawnMascot(name); + } + + private void spawnMascot(String imageSetName) { + if (imageSets.get(imageSetName) == null) { + System.err.println("Invalid spawn, image set not loaded: " + imageSetName); + return; + } + + var m = new Mascot(imageSetName, imgOpts, imageSets); m.setAnchor(new Point(-4000, -4000)); try { @@ -101,45 +105,34 @@ public void imageSetHasBeenAdded(String name, ImageSet imageSet) { } } - @Override - public Integer call() throws Exception { - // temp until i fix the logging - LogManager.getLogManager().reset(); + public void init() { + // setup object w settings + programFolder = pfOpts.toProgramFolder(Constants.JAR_DIR); + imageSets = new ImageSetManager(this, this); + manager = new Manager(); // setup native NativeFactory.init(launchOpts.nativePkg, Constants.NATIVE_LIB_DIR); NativeFactory.getInstance().getEnvironment().init(); + } - // selection - imageSets.setSelected(List.of("dark-shime", "Shimeji")); - - // start manager - var mf = manager.start(); + @Override + public void run() { + // temp until i fix the logging + LogManager.getLogManager().reset(); - // start "UI" can be swing and/or console - var t = new Thread(() -> { - // can't believe im actually using BufferedReader irl - BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - try { - System.out.println("ShimejiEE"); - String str; - while (true) { - System.out.print(">>> "); - str = reader.readLine(); - if (str == null) { - break; - } - System.out.println(str); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - t.start(); + // setup + init(); + // selection + imageSets.setSelected(genOpts.imageSetSelections); - mf.get(); - return 0; + // start manager + try { + manager.start().get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } } private static ImageSet loadImageSet(ShimejiProgramFolder pf, String name, ImageSetOptions options) throws Exception { @@ -169,5 +162,4 @@ private static ImageSet loadImageSet(ShimejiProgramFolder pf, String name, Image return new ShimejiImageSet(config, imgStore, soundStore); } - } diff --git a/src/main/java/com/group_finity/mascotapp/old/Main.java b/src/main/java/com/group_finity/mascotapp/runners/old/Main.java similarity index 93% rename from src/main/java/com/group_finity/mascotapp/old/Main.java rename to src/main/java/com/group_finity/mascotapp/runners/old/Main.java index cd211b1..2760e97 100644 --- a/src/main/java/com/group_finity/mascotapp/old/Main.java +++ b/src/main/java/com/group_finity/mascotapp/runners/old/Main.java @@ -1,4 +1,4 @@ -package com.group_finity.mascotapp.old; +package com.group_finity.mascotapp.runners.old; import com.group_finity.mascot.Mascot; import com.group_finity.mascot.MascotPrefProvider; @@ -14,7 +14,7 @@ import com.group_finity.mascot.imageset.ShimejiProgramFolder; import com.group_finity.mascot.imageset.ShimejiImageSet; import com.group_finity.mascot.sound.SoundLoader; -import com.group_finity.mascot.ui.imagesets.ImageSetChooserUtils; +import com.group_finity.mascotapp.gui.chooser.ImageSetChooserUtils; import com.group_finity.mascotapp.Constants; import org.xml.sax.SAXException; @@ -70,7 +70,7 @@ * * @author see readme */ -public final class Main implements MascotPrefProvider { +public final class Main implements Runnable, MascotPrefProvider { private static final Logger log = Logger.getLogger(Main.class.getName()); // Action that matches the followCursor action @@ -80,32 +80,26 @@ public final class Main implements MascotPrefProvider { private static final String USER_BEHAVIORNAMES_FILE = "user-behaviornames.properties"; - public static final Path JAR_PARENT_DIR; + private static final Path SETTINGS_PATH; static { - System.setProperty("java.util.PropertyResourceBundle.encoding", "UTF-8"); - Path folder = null; - try { - folder = Path.of(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent(); - } catch (Exception e) { - showError("Unable to find path to jar"); - System.exit(1); - } - JAR_PARENT_DIR = folder; - - try (var ins = new FileInputStream(JAR_PARENT_DIR.resolve(Path.of("conf","logging.properties")).toFile())) { + final var logPropsPath = Constants.JAR_DIR.resolve(Path.of("conf","logging.properties")); + try (var ins = new FileInputStream(logPropsPath.toFile())) { LogManager.getLogManager().readConfiguration(ins); } catch (final SecurityException | IOException e) { e.printStackTrace(); } + String settingsPathProp = System.getProperty(SP_PREFIX + "SettingsPath"); + SETTINGS_PATH = settingsPathProp != null + ? Path.of(settingsPathProp) + : Constants.JAR_DIR.resolve(Path.of("conf","settings.properties")); } //--------// - - private ShimejiProgramFolder programFolder = ShimejiProgramFolder.fromFolder(JAR_PARENT_DIR); + private ShimejiProgramFolder programFolder = ShimejiProgramFolder.fromFolder(Constants.JAR_DIR); private final ConcurrentMap loadedImageSets = new ConcurrentHashMap<>(); private final List activeImageSets = new ArrayList<>(); @@ -214,12 +208,49 @@ private void setScaling(double scaling) { //-------------------------------------// - /** - * Program entry point - */ public static void main(final String[] args) { + getInstance().run(); + } + + @Override + public void run() { try { - getInstance().run(); + // init settings + loadAllSettings(SETTINGS_PATH); + Tr.loadLanguage(locale); + Tr.setCustomBehaviorTranslations(loadProperties( + Constants.JAR_DIR.resolve(Path.of("conf", USER_BEHAVIORNAMES_FILE)) + )); + Runtime.getRuntime().addShutdownHook(new Thread(() -> writeAllSettings(SETTINGS_PATH))); + + // tray icon (optional) + createTrayIcon(); + + // init native + final String nativeProp = System.getProperty("com.group_finity.mascotnative", Constants.NATIVE_PKG_DEFAULT); + NativeFactory.init(nativeProp, Constants.NATIVE_LIB_DIR); + NativeFactory.getInstance().getEnvironment().init(); + + // set exit to false because the chooser is async + boolean isExit = manager.isExitOnLastRemoved(); + manager.setExitOnLastRemoved(false); + + Set selections = getActiveImageSets(); + + // get selections (show chooser if needed) + if (selections.isEmpty() || shouldShowChooserAtStart()) { + ImageSetChooserUtils.askUserForSelection(c -> { + setActiveImageSets(c); + manager.setExitOnLastRemoved(isExit); + }, getActiveImageSets(), programFolder); + } else { + selections.forEach(this::addActiveImageSet); + manager.setExitOnLastRemoved(isExit); + } + + // start + manager.start(); + } catch (Exception | Error error) { log.log(Level.SEVERE, error.getMessage(), error); Main.showError(error.getMessage()); @@ -227,46 +258,6 @@ public static void main(final String[] args) { } } - private void run() { - String settingsPathProp = System.getProperty(SP_PREFIX + "SettingsPath"); - final Path SETTINGS_PATH = settingsPathProp != null - ? Path.of(settingsPathProp) - : JAR_PARENT_DIR.resolve(Path.of("conf","settings.properties")); - - loadAllSettings(SETTINGS_PATH); - Tr.loadLanguage(locale); - Tr.setCustomBehaviorTranslations(loadProperties( - JAR_PARENT_DIR.resolve(Path.of("conf", USER_BEHAVIORNAMES_FILE)) - )); - - // optional - createTrayIcon(); - - // init environment - NativeFactory.init(Constants.NATIVE_PKG_DEFAULT, Constants.NATIVE_LIB_DIR); - NativeFactory.getInstance().getEnvironment().init(); - - //because the chooser is async - boolean isExit = manager.isExitOnLastRemoved(); - manager.setExitOnLastRemoved(false); - - Set selections = getActiveImageSets(); - - if (selections.isEmpty() || shouldShowChooserAtStart()) { - ImageSetChooserUtils.askUserForSelection(c -> { - setActiveImageSets(c); - manager.setExitOnLastRemoved(isExit); - }, getActiveImageSets(), programFolder); - } else { - selections.forEach(this::addActiveImageSet); - manager.setExitOnLastRemoved(isExit); - } - - manager.start(); - - Runtime.getRuntime().addShutdownHook(new Thread(() -> writeAllSettings(SETTINGS_PATH))); - } - private static final JFrame frame = new JFrame(); static void showError(String message) { diff --git a/src/main/java/com/group_finity/mascotapp/old/Manager.java b/src/main/java/com/group_finity/mascotapp/runners/old/Manager.java similarity index 99% rename from src/main/java/com/group_finity/mascotapp/old/Manager.java rename to src/main/java/com/group_finity/mascotapp/runners/old/Manager.java index ebee056..68cebbf 100644 --- a/src/main/java/com/group_finity/mascotapp/old/Manager.java +++ b/src/main/java/com/group_finity/mascotapp/runners/old/Manager.java @@ -1,4 +1,4 @@ -package com.group_finity.mascotapp.old; +package com.group_finity.mascotapp.runners.old; import com.group_finity.mascot.Mascot; import com.group_finity.mascot.MascotManager; diff --git a/src/main/java/com/group_finity/mascotnative/macjni/MacJniShimejiWindow.java b/src/main/java/com/group_finity/mascotnative/macjni/MacJniShimejiWindow.java index 835d0dd..311cb0f 100644 --- a/src/main/java/com/group_finity/mascotnative/macjni/MacJniShimejiWindow.java +++ b/src/main/java/com/group_finity/mascotnative/macjni/MacJniShimejiWindow.java @@ -1,7 +1,7 @@ package com.group_finity.mascotnative.macjni; import com.group_finity.mascot.image.NativeImage; -import com.group_finity.mascot.ui.contextmenu.TopLevelMenuRep; +import com.group_finity.mascot.window.contextmenu.TopLevelMenuRep; import com.group_finity.mascot.window.TranslucentWindow; import com.group_finity.mascot.window.TranslucentWindowEvent; import com.group_finity.mascot.window.TranslucentWindowEventHandler; diff --git a/src/main/java/com/group_finity/mascotnative/macjni/menu/MacJniPopupUtil.java b/src/main/java/com/group_finity/mascotnative/macjni/menu/MacJniPopupUtil.java index 3b0616f..6e1bee4 100644 --- a/src/main/java/com/group_finity/mascotnative/macjni/menu/MacJniPopupUtil.java +++ b/src/main/java/com/group_finity/mascotnative/macjni/menu/MacJniPopupUtil.java @@ -1,8 +1,8 @@ package com.group_finity.mascotnative.macjni.menu; -import com.group_finity.mascot.ui.contextmenu.MenuItemRep; -import com.group_finity.mascot.ui.contextmenu.MenuRep; -import com.group_finity.mascot.ui.contextmenu.TopLevelMenuRep; +import com.group_finity.mascot.window.contextmenu.MenuItemRep; +import com.group_finity.mascot.window.contextmenu.MenuRep; +import com.group_finity.mascot.window.contextmenu.TopLevelMenuRep; public class MacJniPopupUtil { diff --git a/src/main/java/com/group_finity/mascotnative/shared/BaseTranslucentSwingWindow.java b/src/main/java/com/group_finity/mascotnative/shared/BaseTranslucentSwingWindow.java index 5fd65b5..d1a38de 100644 --- a/src/main/java/com/group_finity/mascotnative/shared/BaseTranslucentSwingWindow.java +++ b/src/main/java/com/group_finity/mascotnative/shared/BaseTranslucentSwingWindow.java @@ -1,7 +1,7 @@ package com.group_finity.mascotnative.shared; import com.group_finity.mascot.image.NativeImage; -import com.group_finity.mascot.ui.contextmenu.TopLevelMenuRep; +import com.group_finity.mascot.window.contextmenu.TopLevelMenuRep; import com.group_finity.mascot.window.TranslucentWindow; import com.group_finity.mascot.window.TranslucentWindowEvent; import com.group_finity.mascot.window.TranslucentWindowEventHandler; diff --git a/src/main/java/com/group_finity/mascotnative/shared/SwingPopupUtil.java b/src/main/java/com/group_finity/mascotnative/shared/SwingPopupUtil.java index 7f99d54..11b3433 100644 --- a/src/main/java/com/group_finity/mascotnative/shared/SwingPopupUtil.java +++ b/src/main/java/com/group_finity/mascotnative/shared/SwingPopupUtil.java @@ -1,8 +1,8 @@ package com.group_finity.mascotnative.shared; -import com.group_finity.mascot.ui.contextmenu.MenuItemRep; -import com.group_finity.mascot.ui.contextmenu.MenuRep; -import com.group_finity.mascot.ui.contextmenu.TopLevelMenuRep; +import com.group_finity.mascot.window.contextmenu.MenuItemRep; +import com.group_finity.mascot.window.contextmenu.MenuRep; +import com.group_finity.mascot.window.contextmenu.TopLevelMenuRep; import javax.swing.JMenu; import javax.swing.JMenuItem; diff --git a/src/main/java/com/group_finity/mascotnative/virtualdesktop/VirtualWindowPanel.java b/src/main/java/com/group_finity/mascotnative/virtualdesktop/VirtualWindowPanel.java index bf58f73..be19860 100644 --- a/src/main/java/com/group_finity/mascotnative/virtualdesktop/VirtualWindowPanel.java +++ b/src/main/java/com/group_finity/mascotnative/virtualdesktop/VirtualWindowPanel.java @@ -1,7 +1,7 @@ package com.group_finity.mascotnative.virtualdesktop; import com.group_finity.mascot.image.NativeImage; -import com.group_finity.mascot.ui.contextmenu.TopLevelMenuRep; +import com.group_finity.mascot.window.contextmenu.TopLevelMenuRep; import com.group_finity.mascot.window.TranslucentWindow; import com.group_finity.mascot.window.TranslucentWindowEvent; import com.group_finity.mascot.window.TranslucentWindowEventHandler;