cli arg for workdir
This commit is contained in:
+2
-1
@@ -6,4 +6,5 @@
|
|||||||
/build/out/*.jar
|
/build/out/*.jar
|
||||||
/build/in/*.jar
|
/build/in/*.jar
|
||||||
*.log
|
*.log
|
||||||
.attach_pid*
|
.attach_pid*
|
||||||
|
*~
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ $(OUT): $(IN) $(STUB)
|
|||||||
|
|
||||||
|
|
||||||
run: $(OUT)
|
run: $(OUT)
|
||||||
java -jar $(OUT)
|
java -jar $(OUT) -w ../.rogue-save
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OUT)
|
rm -rf $(OUT)
|
||||||
|
|||||||
@@ -67,9 +67,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
|
|||||||
*/
|
*/
|
||||||
initLock();
|
initLock();
|
||||||
|
|
||||||
// hook
|
|
||||||
preInit();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup logging
|
* Setup logging
|
||||||
*/
|
*/
|
||||||
@@ -79,6 +76,9 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
|
|||||||
org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log));
|
org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hook
|
||||||
|
preInit();
|
||||||
|
|
||||||
// only here it makes sense to log.
|
// only here it makes sense to log.
|
||||||
Log.i("=== Starting initialization sequence ===");
|
Log.i("=== Starting initialization sequence ===");
|
||||||
|
|
||||||
|
|||||||
@@ -112,16 +112,16 @@ public class OsUtils {
|
|||||||
switch (getOs()) {
|
switch (getOs()) {
|
||||||
case linux:
|
case linux:
|
||||||
case solaris:
|
case solaris:
|
||||||
file = new File(userhome, "." + dirname + '/');
|
file = new File(userhome, dirname + '/');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case windows:
|
case windows:
|
||||||
final String appdata = System.getenv("APPDATA");
|
final String appdata = System.getenv("APPDATA");
|
||||||
|
|
||||||
if (appdata != null) {
|
if (appdata != null) {
|
||||||
file = new File(appdata, "." + dirname + '/');
|
file = new File(appdata, dirname + '/');
|
||||||
} else {
|
} else {
|
||||||
file = new File(userhome, "." + dirname + '/');
|
file = new File(userhome, dirname + '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mightypork.rogue;
|
|||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import mightypork.gamecore.app.BaseApp;
|
import mightypork.gamecore.app.BaseApp;
|
||||||
@@ -17,6 +18,7 @@ import mightypork.gamecore.logging.writers.LogWriter;
|
|||||||
import mightypork.gamecore.render.DisplaySystem;
|
import mightypork.gamecore.render.DisplaySystem;
|
||||||
import mightypork.gamecore.resources.loading.AsyncResourceLoader;
|
import mightypork.gamecore.resources.loading.AsyncResourceLoader;
|
||||||
import mightypork.gamecore.util.ion.Ion;
|
import mightypork.gamecore.util.ion.Ion;
|
||||||
|
import mightypork.gamecore.util.strings.StringUtils;
|
||||||
import mightypork.rogue.GameStateManager.GameState;
|
import mightypork.rogue.GameStateManager.GameState;
|
||||||
import mightypork.rogue.events.ActionRequest;
|
import mightypork.rogue.events.ActionRequest;
|
||||||
import mightypork.rogue.events.ActionRequest.RequestType;
|
import mightypork.rogue.events.ActionRequest.RequestType;
|
||||||
@@ -45,6 +47,32 @@ public final class App extends BaseApp {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
|
Log.f3(Arrays.toString(args));
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean lwd = false;
|
||||||
|
String lwdDir = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
if (args[i].equals("--workdir") || args[i].equals("-w")) {
|
||||||
|
lwd = true;
|
||||||
|
lwdDir = args[i + 1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lwd) {
|
||||||
|
Paths.init();
|
||||||
|
} else {
|
||||||
|
Paths.init(lwdDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
Log.e("Malformed arguments.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i("Using workdir: " + Paths.WORKDIR.getAbsolutePath());
|
||||||
|
|
||||||
(new App()).start();
|
(new App()).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,25 +3,63 @@ package mightypork.rogue;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import mightypork.gamecore.util.files.OsUtils;
|
||||||
|
|
||||||
|
|
||||||
public final class Paths {
|
public final class Paths {
|
||||||
|
|
||||||
public static final File WORKDIR = new File("./.rogue-save");//OsUtils.getWorkDir(APPDIR_NAME);
|
private static final String WORKDIR_NAME = ".rogue-save";
|
||||||
|
|
||||||
public static final File LOG_FILE = new File(WORKDIR, "runtime.log");
|
public static File WORKDIR;
|
||||||
|
public static File LOG_FILE;
|
||||||
|
public static File SCREENSHOTS;
|
||||||
|
public static File CONFIG;
|
||||||
|
public static File LOCK;
|
||||||
|
|
||||||
public static final File SCREENSHOTS = new File(WORKDIR, "screenshots");
|
public static File SAVE_SLOT_1;
|
||||||
|
public static File SAVE_SLOT_2;
|
||||||
|
public static File SAVE_SLOT_3;
|
||||||
|
|
||||||
public static final File CONFIG = new File(WORKDIR, "config.ini");
|
|
||||||
|
|
||||||
public static final File LOCK = new File(WORKDIR, ".lock");
|
/**
|
||||||
|
* Initialize for local workdir
|
||||||
|
*
|
||||||
|
* @param local_wd_name workdir name
|
||||||
|
*/
|
||||||
|
public static void init(String local_wd_name)
|
||||||
|
{
|
||||||
|
init(true, local_wd_name);
|
||||||
|
}
|
||||||
|
|
||||||
public static final String DIR_EFFECTS = "res/sounds/effects/";
|
|
||||||
public static final String DIR_MUSIC = "res/sounds/music/";
|
|
||||||
public static final String DIR_LOOPS = "res/sounds/loops/";
|
|
||||||
|
|
||||||
public static final File SAVE_SLOT_1 = new File(WORKDIR, "saves/slot_1.ion");
|
/**
|
||||||
public static final File SAVE_SLOT_2 = new File(WORKDIR, "saves/slot_2.ion");
|
* Initialize for gloal workdir
|
||||||
public static final File SAVE_SLOT_3 = new File(WORKDIR, "saves/slot_3.ion");
|
*/
|
||||||
|
public static void init()
|
||||||
|
{
|
||||||
|
init(false, WORKDIR_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void init(boolean local_workdir, String workdir_name)
|
||||||
|
{
|
||||||
|
if (local_workdir) {
|
||||||
|
WORKDIR = new File(workdir_name);
|
||||||
|
} else {
|
||||||
|
WORKDIR = OsUtils.getWorkDir(workdir_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_FILE = new File(WORKDIR, "runtime.log");
|
||||||
|
|
||||||
|
SCREENSHOTS = new File(WORKDIR, "screenshots");
|
||||||
|
|
||||||
|
CONFIG = new File(WORKDIR, "config.ini");
|
||||||
|
|
||||||
|
LOCK = new File(WORKDIR, ".lock");
|
||||||
|
|
||||||
|
SAVE_SLOT_1 = new File(WORKDIR, "saves/slot_1.ion");
|
||||||
|
SAVE_SLOT_2 = new File(WORKDIR, "saves/slot_2.ion");
|
||||||
|
SAVE_SLOT_3 = new File(WORKDIR, "saves/slot_3.ion");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user