# Copyright (C) 2007  Peter De Wachter <pdewacht@gmail.com>
# Distributed under the same license as the game. See debian/copyright.

Sun Aug 26 00:00:45 CEST 2007  pdewacht@gmail.com
  * 07_store_prefs_in_home_dir
Index: a7xpg_0.11.dfsg1/src/abagames/a7xpg/A7xPrefManager.d
===================================================================
--- a7xpg_0.11.dfsg1.orig/src/abagames/a7xpg/A7xPrefManager.d	2007-08-26 23:45:46.000000000 +0200
+++ a7xpg_0.11.dfsg1/src/abagames/a7xpg/A7xPrefManager.d	2007-08-26 23:47:15.000000000 +0200
@@ -5,7 +5,9 @@
  */
 module abagames.a7xpg.A7xPrefManager;
 
-import stream;
+import std.stream;
+import std.c.stdlib;
+import std.string;
 import abagames.util.PrefManager;
 
 /**
@@ -14,18 +16,25 @@
 public class A7xPrefManager: PrefManager {
  public:
   static const int VERSION_NUM = 10;
-  static const char[] PREF_FILE = "a7xpg.prf";
+  static const char[] PREF_FILE = ".a7xpg.prf";
   int hiScore;
 
   private void init() {
     hiScore = 0;
   }
 
+  public char[] pref_file() {
+    char * home = getenv("HOME");
+    if (home is null)
+      throw new Error("HOME environment variable is not defined");
+    return std.string.toString(home) ~ "/" ~ PREF_FILE;
+  }
+
   public void load() {
     auto File fd = new File;
     try {
       int ver;
-      fd.open(PREF_FILE);
+      fd.open(pref_file());
       fd.read(ver);
       if (ver != VERSION_NUM)
 	throw new Error("Wrong version num");
@@ -39,7 +48,7 @@
 
   public void save() {
     auto File fd = new File;
-    fd.create(PREF_FILE);
+    fd.create(pref_file());
     fd.write(VERSION_NUM);
     fd.write(hiScore);
     fd.close();
