* @short_description: Widget which plays an interactive fiction game
* @stability: Unstable
* @include: chimara/chimara-if.h
* @short_description: Widget which plays an interactive fiction game
* @stability: Unstable
* @include: chimara/chimara-if.h
* The #ChimaraIF widget, given an interactive fiction game file to run, selects
* an appropriate interpreter plugin and runs it. Interpreter options are set by
* setting properties on the widget.
* The #ChimaraIF widget, given an interactive fiction game file to run, selects
* an appropriate interpreter plugin and runs it. Interpreter options are set by
* setting properties on the widget.
gchar *response = g_string_free(priv->response, FALSE);
priv->response = g_string_new("");
gchar *response = g_string_free(priv->response, FALSE);
priv->response = g_string_new("");
g_signal_emit_by_name(glk, "command", priv->input, response);
g_signal_emit_by_name(glk, "command", priv->input, response);
chimara_if_stopped(ChimaraGlk *glk)
{
CHIMARA_IF_USE_PRIVATE(glk, priv);
chimara_if_stopped(ChimaraGlk *glk)
{
CHIMARA_IF_USE_PRIVATE(glk, priv);
if(priv->input || priv->response->len > 0)
chimara_if_waiting(glk); /* Send one last command signal */
if(priv->input || priv->response->len > 0)
chimara_if_waiting(glk); /* Send one last command signal */
/* Connect to signals of ChimaraGlk parent */
g_signal_connect(self, "stopped", G_CALLBACK(chimara_if_stopped), NULL);
g_signal_connect(self, "waiting", G_CALLBACK(chimara_if_waiting), NULL);
/* Connect to signals of ChimaraGlk parent */
g_signal_connect(self, "stopped", G_CALLBACK(chimara_if_stopped), NULL);
g_signal_connect(self, "waiting", G_CALLBACK(chimara_if_waiting), NULL);
* @self: The widget that received the signal
* @input: The command typed into the game
* @response: The game's response to the command
* @self: The widget that received the signal
* @input: The command typed into the game
* @response: The game's response to the command
* Emitted once for each input-response cycle of an interactive fiction
* game. Note that games with nontraditional input systems (i.e. not all
* Emitted once for each input-response cycle of an interactive fiction
* game. Note that games with nontraditional input systems (i.e. not all
* The Z-machine specification defines a facility for games to ask the
* interpreter they are running on whether this copy of the game is pirated.
* How the interpreter is supposed to magically determine that it is running
* pirate software is unclear, and so the majority of games and interpreters
* ignore this feature. Set this property to %TRUE if you want the
* interpreter to pretend it has detected a pirated game.
* The Z-machine specification defines a facility for games to ask the
* interpreter they are running on whether this copy of the game is pirated.
* How the interpreter is supposed to magically determine that it is running
* pirate software is unclear, and so the majority of games and interpreters
* ignore this feature. Set this property to %TRUE if you want the
* interpreter to pretend it has detected a pirated game.
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_PIRACY_MODE,
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_PIRACY_MODE,
_("Pretend the game is pirated"), FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:tandy-bit:
_("Pretend the game is pirated"), FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:tandy-bit:
- * property to %TRUE changes the wording of some Version 3 Infocom games
- * slightly, so as to be less offensive. See <ulink
+ * property to %TRUE changes the wording of some Version 3 Infocom games
+ * slightly, so as to be less offensive. See <ulink
* url="http://www.ifarchive.org/if-archive/infocom/info/tandy_bits.html">
* http://www.ifarchive.org/if-archive/infocom/info/tandy_bits.html</ulink>.
* url="http://www.ifarchive.org/if-archive/infocom/info/tandy_bits.html">
* http://www.ifarchive.org/if-archive/infocom/info/tandy_bits.html</ulink>.
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_TANDY_BIT,
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_TANDY_BIT,
- g_param_spec_boolean("tandy-bit", _("Tandy bit"),
- _("Censor certain Infocom games"), FALSE,
+ g_param_spec_boolean("tandy-bit", _("Tandy bit"),
+ _("Censor certain Infocom games"), FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:expand-abbreviations:
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:expand-abbreviations:
* library, support the following one-letter abbreviations:
* <simplelist>
* <member>D — Down</member>
* library, support the following one-letter abbreviations:
* <simplelist>
* <member>D — Down</member>
* <member>Z — wait (ZZZZ...)</member>
* </simplelist>
* Some early Infocom games might not recognize these abbreviations. Setting
* <member>Z — wait (ZZZZ...)</member>
* </simplelist>
* Some early Infocom games might not recognize these abbreviations. Setting
- * this property to %TRUE will cause the interpreter to expand the
- * abbreviations to the full words before passing the commands on to the
- * game. Frotz only expands G, X, and Z; Nitfol expands all of the above
+ * this property to %TRUE will cause the interpreter to expand the
+ * abbreviations to the full words before passing the commands on to the
+ * game. Frotz only expands G, X, and Z; Nitfol expands all of the above
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:ignore-errors:
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:ignore-errors:
* Setting this property to %TRUE will cause the interpreter to ignore
* certain Z-machine runtime errors. Frotz will ignore any fatal errors.
* Nitfol by default warns about any shady behavior, and this property will
* turn those warnings off.
* Setting this property to %TRUE will cause the interpreter to ignore
* certain Z-machine runtime errors. Frotz will ignore any fatal errors.
* Nitfol by default warns about any shady behavior, and this property will
* turn those warnings off.
_("Do not warn the user about Z-machine errors"), FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:typo-correction:
_("Do not warn the user about Z-machine errors"), FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:typo-correction:
* Nitfol has an automatic typo-correction facility, where it searches the
* game dictionary for words which differ by one letter from any unknown
* input words. Set this property to %FALSE to turn this feature off.
* Nitfol has an automatic typo-correction facility, where it searches the
* game dictionary for words which differ by one letter from any unknown
* input words. Set this property to %FALSE to turn this feature off.
*/
g_object_class_install_property(object_class, PROP_TYPO_CORRECTION,
g_param_spec_boolean("typo-correction", _("Typo correction"),
*/
g_object_class_install_property(object_class, PROP_TYPO_CORRECTION,
g_param_spec_boolean("typo-correction", _("Typo correction"),
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:interpreter-number:
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:interpreter-number:
* and Nitfol plugins can emulate any of these platforms. Some games behave
* slightly differently depending on what platform they are on. Set this
* property to a #ChimaraIFZmachineVersion value to emulate a certain
* platform.
* and Nitfol plugins can emulate any of these platforms. Some games behave
* slightly differently depending on what platform they are on. Set this
* property to a #ChimaraIFZmachineVersion value to emulate a certain
* platform.
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_INTERPRETER_NUMBER,
g_param_spec_uint("interpreter-number", _("Interpreter number"),
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_INTERPRETER_NUMBER,
g_param_spec_uint("interpreter-number", _("Interpreter number"),
CHIMARA_IF_ZMACHINE_DEFAULT, CHIMARA_IF_ZMACHINE_MAXVAL, CHIMARA_IF_ZMACHINE_DEFAULT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:random-seed:
CHIMARA_IF_ZMACHINE_DEFAULT, CHIMARA_IF_ZMACHINE_MAXVAL, CHIMARA_IF_ZMACHINE_DEFAULT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
/**
* ChimaraIF:random-seed:
* If the #ChimaraIF:random-seed-set property is %TRUE, then the interpreter
* will use the value of this property as a seed for the random number
* generator. Use this feature to duplicate sequences of random numbers
* for testing games.
* If the #ChimaraIF:random-seed-set property is %TRUE, then the interpreter
* will use the value of this property as a seed for the random number
* generator. Use this feature to duplicate sequences of random numbers
* for testing games.
* Note that the value -1 is a valid random number seed for
* Nitfol, whereas it will cause Frotz to pick an arbitrary seed even when
* #ChimaraIF:random-seed-set is %TRUE.
* Note that the value -1 is a valid random number seed for
* Nitfol, whereas it will cause Frotz to pick an arbitrary seed even when
* #ChimaraIF:random-seed-set is %TRUE.
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_RANDOM_SEED_SET,
* Only affects Z-machine interpreters.
*/
g_object_class_install_property(object_class, PROP_RANDOM_SEED_SET,
* @self: A #ChimaraIF widget.
* @format: The game format to set the preferred interpreter plugin for.
* @interpreter: The preferred interpreter plugin for @format.
* @self: A #ChimaraIF widget.
* @format: The game format to set the preferred interpreter plugin for.
* @interpreter: The preferred interpreter plugin for @format.
* The function chimara_if_run_game() picks an appropriate interpreter for the
* type of game file it is given. This function sets which interpreter is picked
* for a certain game file format. Most formats, notably the Z-machine, have
* The function chimara_if_run_game() picks an appropriate interpreter for the
* type of game file it is given. This function sets which interpreter is picked
* for a certain game file format. Most formats, notably the Z-machine, have
* chimara_if_get_preferred_interpreter:
* @self: A #ChimaraIF widget.
* @format: The game format to query the preferred interpreter plugin for.
* chimara_if_get_preferred_interpreter:
* @self: A #ChimaraIF widget.
* @format: The game format to query the preferred interpreter plugin for.
* Looks up the preferred interpreter for the game file format @format. See
* chimara_if_set_preferred_interpreter().
* Looks up the preferred interpreter for the game file format @format. See
* chimara_if_set_preferred_interpreter().
* @self: A #ChimaraIF widget.
* @gamefile: Path to an interactive fiction game file.
* @error: Return location for an error, or %NULL.
* @self: A #ChimaraIF widget.
* @gamefile: Path to an interactive fiction game file.
* @error: Return location for an error, or %NULL.
* Autodetects the type of a game file and runs it using an appropriate
* interpreter plugin. If there is more than one interpreter that supports the
* Autodetects the type of a game file and runs it using an appropriate
* interpreter plugin. If there is more than one interpreter that supports the
chimara_if_run_game(ChimaraIF *self, gchar *gamefile, GError **error)
{
g_return_val_if_fail(self && CHIMARA_IS_IF(self), FALSE);
g_return_val_if_fail(gamefile, FALSE);
chimara_if_run_game(ChimaraIF *self, gchar *gamefile, GError **error)
{
g_return_val_if_fail(self && CHIMARA_IS_IF(self), FALSE);
g_return_val_if_fail(gamefile, FALSE);
CHIMARA_IF_USE_PRIVATE(self, priv);
/* Find out what format the game is */
CHIMARA_IF_USE_PRIVATE(self, priv);
/* Find out what format the game is */
format = CHIMARA_IF_FORMAT_GLULX;
else if(g_str_has_suffix(gamefile, ".blb") || g_str_has_suffix(gamefile, ".blorb") || g_str_has_suffix(gamefile, ".glb") || g_str_has_suffix(gamefile, ".gblorb"))
format = CHIMARA_IF_FORMAT_GLULX_BLORB;
format = CHIMARA_IF_FORMAT_GLULX;
else if(g_str_has_suffix(gamefile, ".blb") || g_str_has_suffix(gamefile, ".blorb") || g_str_has_suffix(gamefile, ".glb") || g_str_has_suffix(gamefile, ".gblorb"))
format = CHIMARA_IF_FORMAT_GLULX_BLORB;
/* Now decide what interpreter to use */
ChimaraIFInterpreter interpreter = priv->preferred_interpreter[format];
gchar *pluginfile = g_strconcat(plugin_names[interpreter], "." G_MODULE_SUFFIX, NULL);
/* Now decide what interpreter to use */
ChimaraIFInterpreter interpreter = priv->preferred_interpreter[format];
gchar *pluginfile = g_strconcat(plugin_names[interpreter], "." G_MODULE_SUFFIX, NULL);
- gchar *pluginpath = g_build_filename("..", "interpreters", plugin_names[interpreter], LT_OBJDIR, pluginfile, NULL);
- if( !g_file_test(pluginpath, G_FILE_TEST_EXISTS) )
+ pluginpath = g_build_filename(PLUGINSOURCEDIR, plugin_names[interpreter], LT_OBJDIR, pluginfile, NULL);
+ if( !g_file_test(pluginpath, G_FILE_TEST_EXISTS) )
{
g_free(pluginpath);
g_free(pluginfile);
g_set_error(error, CHIMARA_ERROR, CHIMARA_PLUGIN_NOT_FOUND, _("No appropriate %s interpreter plugin was found"), interpreter_names[interpreter]);
return FALSE;
}
{
g_free(pluginpath);
g_free(pluginfile);
g_set_error(error, CHIMARA_ERROR, CHIMARA_PLUGIN_NOT_FOUND, _("No appropriate %s interpreter plugin was found"), interpreter_names[interpreter]);
return FALSE;
}
/* Allocate argv to hold the arguments */
int argc = g_slist_length(args);
args = g_slist_prepend(args, NULL);
char **argv = g_new0(char *, argc + 1);
/* Allocate argv to hold the arguments */
int argc = g_slist_length(args);
args = g_slist_prepend(args, NULL);
char **argv = g_new0(char *, argc + 1);
/* Fill argv */
args = g_slist_reverse(args);
int count;
GSList *ptr;
for(count = 0, ptr = args; ptr; count++, ptr = g_slist_next(ptr))
argv[count] = ptr->data;
/* Fill argv */
args = g_slist_reverse(args);
int count;
GSList *ptr;
for(count = 0, ptr = args; ptr; count++, ptr = g_slist_next(ptr))
argv[count] = ptr->data;
gboolean retval = chimara_glk_run(CHIMARA_GLK(self), pluginpath, argc, argv, error);
g_free(argv);
if(terpnumstr)
gboolean retval = chimara_glk_run(CHIMARA_GLK(self), pluginpath, argc, argv, error);
g_free(argv);
if(terpnumstr)