1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Documentation on plugins, and code to support multiple versions of plugin import module.

This commit is contained in:
Joe R 2023-02-15 19:29:40 -05:00
parent 007f930066
commit 20096a88c8
5 changed files with 37 additions and 6 deletions

View file

@ -64,6 +64,7 @@ files = [
('assist_options.html', 'PySol - Assist Options'),
('solitaire_wizard.html', 'PySol - Solitaire Wizard'),
('cardset_customization.html', 'PySol - Cardset Customization'),
('plugins.html', 'PySol - Plugins'),
]
rules_files = [

View file

@ -16,6 +16,7 @@
<li> <a href="assist_options.html">Assist Options</a>
<li> <a href="solitaire_wizard.html">Solitaire Wizard</a>
<li> <a href="cardset_customization.html">Cardset Customization</a>
<li> <a href="plugins.html">Plugins</a>
</ul>
<h2>Misc</h2>
<ul>

14
html-src/plugins.html Normal file
View 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.

View file

@ -1,11 +1,13 @@
<h1>Solitaire Wizard</h1>
<p>
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>
Also note that the Solitaire Wizard may not be enabled in mobile versions of
PySol.
<p>
Below are the different options you can set when using the Solitaire Wizard:
<h2>General</h2>

View file

@ -21,9 +21,6 @@
#
# ---------------------------------------------------------------------------##
import imp
import pysollib.settings
from pysollib.mfxutil import Struct, print_err
from pysollib.mygettext import _, n_
@ -31,6 +28,16 @@ from pysollib.resource import CSI
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
# ************************************************************************
@ -862,6 +869,12 @@ def loadGame(modname, filename, check_game=False):
# print "load game", modname, filename
GAME_DB.check_game = check_game
GAME_DB.current_filename = filename
imp.load_source(modname, 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)
# execfile(filename, globals(), globals())
GAME_DB.current_filename = None