12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/usr/bin/env python
- #! coding: utf-8
- #! python3
- # Kazeged 2022
- import sys
- import argparse
- import os
- import random
- import engine
- #==============================================================================
- # Gather arguments
- #==============================================================================
- def Args():
- parser = argparse.ArgumentParser()
- parser.add_argument( "-g", "--game-folder", default=None, dest="gameFolder", help="Auto load a game folder" )
- parser.add_argument( "-l", "--game-lib-folder", default=None, dest="gameLibFolder", help="Change the game lib folder" )
- parser.add_argument( "-f", "--force-selection", default=False, action="store_true", dest="forceSelection", help="Force game selection from lib" )
- parser.add_argument( "-s", "--skip-intro", default=False, action="store_true", dest="skipIntro", help="Skips intro" )
- return parser.parse_args()
- #==============================================================================
- # Main program
- #==============================================================================
- if getattr( sys, 'frozen', False ) :
- scriptPath = os.path.dirname( sys.executable )
- elif __file__:
- scriptPath = os.path.dirname( __file__ )
- args = Args()
- # Check parameters: Skip engine intro?
- if args.skipIntro == False : engine.intro()
- # Check parameters: Change game lib folder?
- #TODO change default setting for MyDoccuments/home
- gameLibFolder = os.path.join( scriptPath, "gamelib" )
- if args.gameLibFolder :
- if os.path.exists( args.gameLibFolder ) :
- gameLibFolder = args.gameLibFolder
-
- # Check parameters: Auto load a game folder?
- gameFolder = None
- # Load different games depending on the case
- if args.gameFolder :
- if os.path.exists( args.gameFolder ) :
- gameFolder = args.gameFolder
-
- else :
- # Load the default game folder
- if os.path.exists( os.path.join( scriptPath, "game" ) ) :
- gameFolder = os.path.join( scriptPath, "game" )
-
- # Fallback: a small interface to choose the game to load if none given
- # or the user asked for the game selector
- if (gameFolder == None) or (args.forceSelection) :
- gameFolder = engine.game_selection( gameLibFolder )
- # Start the game
- engine.game_start( gameFolder )
- # Stop the engine
- engine.game_end()
|