Dummy sound should know about foreground as well
[naja.git] / naja / options.py
index cf5715dde1faa36d7dcf81628648458434c3b3fc..6fe75660987b364ab138dc5144156123c72d9b3c 100644 (file)
@@ -1,15 +1,11 @@
 import optparse
 import os
+import sys
 
+from naja.attrdict import AttrDict
 from naja.constants import DEFAULTS
 
 
-class AttrDict(dict):
-    '''A dict with attribute access'''
-    def __getattr__(self, attr):
-        return self[attr]
-
-
 options = AttrDict()
 
 
@@ -33,8 +29,34 @@ def parse_args(args):
                       dest='music', action='store_false', default=True,
                       help='Disable music (but not sound)')
 
+    parser.add_option("--save-location", default=_get_default_save_location(),
+                      dest="save_location", help="Saved game location")
+
+    if options.debug:
+        parser.add_option('--initial-bits', type=int,
+                          help='Initial player bits')
+        parser.add_option('--cheat-enabled', default=False,
+                          action='store_true',
+                          help='For those too lazy to type the KONAMI code')
+        parser.add_option('--deck', default=None,
+                          help='Start with a new game for a specific deck')
+        parser.add_option('--load', default=None,
+                          help='Start with a specific save game loaded')
+
     opts, _ = parser.parse_args(args)
 
     for k in DEFAULTS:
         if getattr(opts, k, None) is not None:
             options[k] = getattr(opts, k)
+
+
+def _get_default_save_location():
+    """Return a default save game location."""
+    app = "naja"
+    if sys.platform.startswith("win"):
+        if "APPDATA" in os.environ:
+            return os.path.join(os.environ["APPDATA"], app)
+        return os.path.join(os.path.expanduser("~"), "." + app)
+    elif 'XDG_DATA_HOME' in os.environ:
+        return os.path.join(os.environ["XDG_DATA_HOME"], app)
+    return os.path.join(os.path.expanduser("~"), ".local", "share", app)