mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-15 02:54:09 -04:00
Documentation on plugins, and code to support multiple versions of plugin import module.
This commit is contained in:
parent
007f930066
commit
20096a88c8
5 changed files with 37 additions and 6 deletions
|
@ -64,6 +64,7 @@ files = [
|
||||||
('assist_options.html', 'PySol - Assist Options'),
|
('assist_options.html', 'PySol - Assist Options'),
|
||||||
('solitaire_wizard.html', 'PySol - Solitaire Wizard'),
|
('solitaire_wizard.html', 'PySol - Solitaire Wizard'),
|
||||||
('cardset_customization.html', 'PySol - Cardset Customization'),
|
('cardset_customization.html', 'PySol - Cardset Customization'),
|
||||||
|
('plugins.html', 'PySol - Plugins'),
|
||||||
]
|
]
|
||||||
|
|
||||||
rules_files = [
|
rules_files = [
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<li> <a href="assist_options.html">Assist Options</a>
|
<li> <a href="assist_options.html">Assist Options</a>
|
||||||
<li> <a href="solitaire_wizard.html">Solitaire Wizard</a>
|
<li> <a href="solitaire_wizard.html">Solitaire Wizard</a>
|
||||||
<li> <a href="cardset_customization.html">Cardset Customization</a>
|
<li> <a href="cardset_customization.html">Cardset Customization</a>
|
||||||
|
<li> <a href="plugins.html">Plugins</a>
|
||||||
</ul>
|
</ul>
|
||||||
<h2>Misc</h2>
|
<h2>Misc</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
14
html-src/plugins.html
Normal file
14
html-src/plugins.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<h1>Plugins</h1>
|
||||||
|
<p>
|
||||||
|
PySolFC can support adding additional games, or making other modifications
|
||||||
|
by writing Python scripts that work as plugins. These scripts can be added
|
||||||
|
to the plugins folder of your user folder or the PySolFC installation directory.
|
||||||
|
Plugins can be used to create and add games that are too complex for the
|
||||||
|
<a href='solitaire_wizard.html'>Solitaire Wizard</a> options.
|
||||||
|
<p>
|
||||||
|
A couple sample plugins are available for download on the PySolFC website
|
||||||
|
<a href='https://sourceforge.net/projects/pysolfc/files/Sample%20Plugins/'>here</a>.
|
||||||
|
These plugins recreate a couple of PySol's more complex games, including
|
||||||
|
<a href='rules/demonsandthieves.html'>Demons and Thieves</a> and
|
||||||
|
<a href='rules/crossword.html'>Crossword</a> and can be used as a guide to
|
||||||
|
help write your own plugins.
|
|
@ -1,11 +1,13 @@
|
||||||
<h1>Solitaire Wizard</h1>
|
<h1>Solitaire Wizard</h1>
|
||||||
<p>
|
<p>
|
||||||
The Solitaire Wizard is a feature in PySol that allows you to create and play
|
The Solitaire Wizard is a feature in PySol that allows you to create and play
|
||||||
custom solitaire games.
|
custom solitaire games. The Solitaire Wizard is an easy way to create custom
|
||||||
|
games, though its options are a bit limited. More complex games can be created
|
||||||
|
with <a href='plugins.html'>plugins</a>.
|
||||||
<p>
|
<p>
|
||||||
Also note that the Solitaire Wizard may not be enabled in mobile versions of
|
Also note that the Solitaire Wizard may not be enabled in mobile versions of
|
||||||
PySol.
|
PySol.
|
||||||
|
<p>
|
||||||
Below are the different options you can set when using the Solitaire Wizard:
|
Below are the different options you can set when using the Solitaire Wizard:
|
||||||
|
|
||||||
<h2>General</h2>
|
<h2>General</h2>
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
#
|
#
|
||||||
# ---------------------------------------------------------------------------##
|
# ---------------------------------------------------------------------------##
|
||||||
|
|
||||||
|
|
||||||
import imp
|
|
||||||
|
|
||||||
import pysollib.settings
|
import pysollib.settings
|
||||||
from pysollib.mfxutil import Struct, print_err
|
from pysollib.mfxutil import Struct, print_err
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _, n_
|
||||||
|
@ -31,6 +28,16 @@ from pysollib.resource import CSI
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
# Handle import of import library - different libraries are needed
|
||||||
|
# for different Python versions.
|
||||||
|
imp = None
|
||||||
|
util = None
|
||||||
|
try:
|
||||||
|
from importlib import util
|
||||||
|
except ImportError:
|
||||||
|
util = None
|
||||||
|
import imp
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * constants
|
# * constants
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -862,6 +869,12 @@ def loadGame(modname, filename, check_game=False):
|
||||||
# print "load game", modname, filename
|
# print "load game", modname, filename
|
||||||
GAME_DB.check_game = check_game
|
GAME_DB.check_game = check_game
|
||||||
GAME_DB.current_filename = filename
|
GAME_DB.current_filename = filename
|
||||||
|
if util is not None:
|
||||||
|
spec = util.spec_from_file_location(modname, filename)
|
||||||
|
module = util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
else:
|
||||||
imp.load_source(modname, filename)
|
imp.load_source(modname, filename)
|
||||||
|
|
||||||
# execfile(filename, globals(), globals())
|
# execfile(filename, globals(), globals())
|
||||||
GAME_DB.current_filename = None
|
GAME_DB.current_filename = None
|
||||||
|
|
Loading…
Add table
Reference in a new issue