Ondřej Hruška 11 years ago
commit baee0883b6
  1. 3
      .gitignore
  2. 2
      build/Makefile
  3. BIN
      build/stub-old.jar
  4. BIN
      build/stub.jar
  5. 8
      src/mightypork/gamecore/app/BaseApp.java
  6. 6
      src/mightypork/gamecore/util/files/OsUtils.java
  7. 28
      src/mightypork/rogue/App.java
  8. 60
      src/mightypork/rogue/Paths.java

3
.gitignore vendored

@ -6,4 +6,5 @@
/build/out/*.jar
/build/in/*.jar
*.log
.attach_pid*
.attach_pid*
*~

@ -34,7 +34,7 @@ $(OUT): $(IN) $(STUB)
run: $(OUT)
java -jar $(OUT)
java -jar $(OUT) -w ../.rogue-save
clean:
rm -rf $(OUT)

Binary file not shown.

Binary file not shown.

@ -67,9 +67,6 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
*/
initLock();
// hook
preInit();
/*
* Setup logging
*/
@ -79,9 +76,12 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
org.newdawn.slick.util.Log.setLogSystem(new SlickLogRedirector(log));
}
// only here it makes sense to log.
Log.i("=== Starting initialization sequence ===");
// hook
preInit();
/*
* Ionizables

@ -112,16 +112,16 @@ public class OsUtils {
switch (getOs()) {
case linux:
case solaris:
file = new File(userhome, "." + dirname + '/');
file = new File(userhome, dirname + '/');
break;
case windows:
final String appdata = System.getenv("APPDATA");
if (appdata != null) {
file = new File(appdata, "." + dirname + '/');
file = new File(appdata, dirname + '/');
} else {
file = new File(userhome, "." + dirname + '/');
file = new File(userhome, dirname + '/');
}
break;

@ -2,6 +2,7 @@ package mightypork.rogue;
import java.io.File;
import java.util.Arrays;
import java.util.Locale;
import mightypork.gamecore.app.BaseApp;
@ -18,6 +19,7 @@ import mightypork.gamecore.logging.writers.LogWriter;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.loading.AsyncResourceLoader;
import mightypork.gamecore.util.ion.Ion;
import mightypork.gamecore.util.strings.StringUtils;
import mightypork.rogue.GameStateManager.GameState;
import mightypork.rogue.events.ActionRequest;
import mightypork.rogue.events.ActionRequest.RequestType;
@ -47,6 +49,32 @@ public final class App extends BaseApp {
*/
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();
}

@ -3,25 +3,63 @@ package mightypork.rogue;
import java.io.File;
import mightypork.gamecore.util.files.OsUtils;
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 File WORKDIR;
public static File LOG_FILE;
public static File SCREENSHOTS;
public static File CONFIG;
public static File LOCK;
public static File SAVE_SLOT_1;
public static File SAVE_SLOT_2;
public static File SAVE_SLOT_3;
public static final File LOG_FILE = new File(WORKDIR, "runtime.log");
public static final File SCREENSHOTS = new File(WORKDIR, "screenshots");
/**
* 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 File CONFIG = new File(WORKDIR, "config.ini");
public static final File LOCK = new File(WORKDIR, ".lock");
/**
* Initialize for gloal workdir
*/
public static void init()
{
init(false, WORKDIR_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");
public static final File SAVE_SLOT_3 = new File(WORKDIR, "saves/slot_3.ion");
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");
}
}

Loading…
Cancel
Save