ChimaraIF

ChimaraIF — Widget which plays an interactive fiction game

Stability Level

Unstable, unless otherwise indicated

Functions

Properties

gboolean expand-abbreviations Read / Write / Construct
char * graphics-file Read / Write / Construct
gboolean ignore-errors Read / Write / Construct
guint interpreter-number Read / Write / Construct
gboolean piracy-mode Read / Write / Construct
int random-seed Read / Write
gboolean random-seed-set Read / Write / Construct
gboolean tandy-bit Read / Write / Construct
gboolean typo-correction Read / Write / Construct

Signals

void command  

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkContainer
                ╰── ChimaraGlk
                    ╰── ChimaraIF

Implemented Interfaces

ChimaraIF implements AtkImplementorIface and GtkBuildable.

Includes

#include <libchimara/chimara-if.h>

Description

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.

Using it in a GTK program is similar to using ChimaraGlk (which see). Use chimara_if_run_game() to start playing an interactive fiction game.

Functions

chimara_if_new ()

GtkWidget *
chimara_if_new (void);

Creates and initializes a new ChimaraIF widget.

Returns

a ChimaraIF widget, with a floating reference.


chimara_if_set_preferred_interpreter ()

void
chimara_if_set_preferred_interpreter (ChimaraIF *self,
                                      ChimaraIFFormat format,
                                      ChimaraIFInterpreter interpreter);

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 had many different interpreters written for them over the years, all with slightly different quirks and capabilities, so there is plenty of choice.

Parameters

self

A ChimaraIF widget.

 

format

The game format to set the preferred interpreter plugin for.

 

interpreter

The preferred interpreter plugin for format .

 

chimara_if_get_preferred_interpreter ()

ChimaraIFInterpreter
chimara_if_get_preferred_interpreter (ChimaraIF *self,
                                      ChimaraIFFormat format);

Looks up the preferred interpreter for the game file format format . See chimara_if_set_preferred_interpreter().

Parameters

self

A ChimaraIF widget.

 

format

The game format to query the preferred interpreter plugin for.

 

Returns

a ChimaraIFInterpreter value representing the preferred interpreter plugin for format .


chimara_if_run_game ()

gboolean
chimara_if_run_game (ChimaraIF *self,
                     const char *game_path,
                     GError **error);

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 file format, the preferred one will be picked, according to chimara_if_set_preferred_interpreter().

Parameters

self

A ChimaraIF widget.

 

game_path

Path to an interactive fiction game file.

 

error

Return location for an error, or NULL.

 

Returns

TRUE if the game was started successfully, FALSE if not, in which case error is set.


chimara_if_run_game_file ()

gboolean
chimara_if_run_game_file (ChimaraIF *self,
                          GFile *game_file,
                          GError **error);

Autodetects the type of a game file and runs it using an appropriate interpreter plugin. See chimara_if_run_game() for more information.

Parameters

self

A ChimaraIF widget.

 

game_file

a GFile pointing to an interactive fiction game file.

 

error

Return location for an error, or NULL.

 

Returns

TRUE if the game was started successfully, FALSE if not, in which case error is set.


chimara_if_get_format ()

ChimaraIFFormat
chimara_if_get_format (ChimaraIF *self);

Returns the file format of the currently running game.

Parameters

self

A ChimaraIF widget.

 

Returns

a ChimaraIFFormat constant.


chimara_if_get_interpreter ()

ChimaraIFInterpreter
chimara_if_get_interpreter (ChimaraIF *self);

Returns the interpreter plugin currently running.

Parameters

self

A ChimaraIF widget.

 

Returns

a ChimaraIFInterpreter constant.

Types and Values

enum ChimaraIFFormat

Constants representing all game formats supported by the Chimara system.

Members

CHIMARA_IF_FORMAT_Z5

Z-code version 5

 

CHIMARA_IF_FORMAT_Z6

Z-code version 6

 

CHIMARA_IF_FORMAT_Z8

Z-code version 8

 

CHIMARA_IF_FORMAT_Z_BLORB

Blorbed Z-code

 

CHIMARA_IF_FORMAT_GLULX

Glulx

 

CHIMARA_IF_FORMAT_GLULX_BLORB

Blorbed Glulx

 

enum ChimaraIFInterpreter

Constants representing the available interpreter plugins.

Members

CHIMARA_IF_INTERPRETER_FROTZ

Frotz

 

CHIMARA_IF_INTERPRETER_NITFOL

Nitfol

 

CHIMARA_IF_INTERPRETER_GLULXE

Glulxe

 

CHIMARA_IF_INTERPRETER_GIT

Git

 

CHIMARA_IF_INTERPRETER_BOCFEL

Bocfel

 

enum ChimaraIFZmachineVersion

Allowed values for the “interpreter-number” property. All trademarks are the property of their respective owners.

Members

CHIMARA_IF_ZMACHINE_DEFAULT

Use the interpreter's default interpreter number.

 

CHIMARA_IF_ZMACHINE_DECSYSTEM_20

DEC System 20

 

CHIMARA_IF_ZMACHINE_APPLE_IIE

Apple IIe

 

CHIMARA_IF_ZMACHINE_MACINTOSH

Apple Macintosh

 

CHIMARA_IF_ZMACHINE_AMIGA

Commodore Amiga

 

CHIMARA_IF_ZMACHINE_ATARI_ST

Atari ST

 

CHIMARA_IF_ZMACHINE_IBM_PC

IBM PC

 

CHIMARA_IF_ZMACHINE_COMMODORE_128

Commodore 128

 

CHIMARA_IF_ZMACHINE_COMMODORE_64

Commodore 64

 

CHIMARA_IF_ZMACHINE_APPLE_IIC

Apple IIc

 

CHIMARA_IF_ZMACHINE_APPLE_IIGS

Apple IIgs

 

CHIMARA_IF_ZMACHINE_TANDY_COLOR

Tandy Color Computer

 

ChimaraIF

typedef struct _ChimaraIF ChimaraIF;

This structure contains no public members.

Property Details

The “expand-abbreviations” property

  “expand-abbreviations”     gboolean

Most Z-machine games, in particular ones compiled with the Inform library, support the following one-letter abbreviations:

D — Down
E — East
G — aGain
I — Inventory
L — Look
N — North
O — Oops
Q — Quit
S — South
U — Up
W — West
X — eXamine
Y — Yes
Z — wait (ZZZZ...)

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 plus the following nonstandard ones:

C — Close
K — attacK
P — oPen
R — dRop
T — Take

Only affects Z-machine interpreters. Behaves differently on Frotz and Nitfol.

Owner: ChimaraIF

Flags: Read / Write / Construct

Default value: FALSE


The “graphics-file” property

  “graphics-file”            char *

Some Z-machine interpreters accept an extra argument that indicates a separate Blorb file containing graphics and sound resources. The interpreter will check if the file specified in this property really exists, and if so, use it as a resource file. If this property is set to NULL, the interpreter will not look for an extra file.

Only affects Frotz and Nitfol.

Owner: ChimaraIF

Flags: Read / Write / Construct

Default value: NULL


The “ignore-errors” property

  “ignore-errors”            gboolean

Setting this property to TRUE will cause the interpreter to ignore certain Z-machine runtime errors. If this is turned on, Frotz will ignore any fatal errors. Nitfol, on the other hand, will warn about any shady behavior at all if this is turned off.

Only affects Z-machine interpreters. Behaves differently on Frotz and Nitfol.

Owner: ChimaraIF

Flags: Read / Write / Construct

Default value: FALSE


The “interpreter-number” property

  “interpreter-number”       guint

Infocom gave each port of their interpreter a different number. The Frotz 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.

Note that Nitfol pretends to be an Apple IIe by default.

Only affects Z-machine interpreters.

Owner: ChimaraIF

Flags: Read / Write / Construct

Allowed values: <= 11

Default value: 0


The “piracy-mode” property

  “piracy-mode”              gboolean

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.

Owner: ChimaraIF

Flags: Read / Write / Construct

Default value: FALSE


The “random-seed” property

  “random-seed”              int

If the “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 “random-seed-set” is TRUE.

Only affects Z-machine interpreters. Behaves slightly differently on Frotz and Nitfol.

Owner: ChimaraIF

Flags: Read / Write

Default value: 0


The “random-seed-set” property

  “random-seed-set”          gboolean

Whether to use or ignore the “random-seed” property.

Only affects Z-machine interpreters.

Owner: ChimaraIF

Flags: Read / Write / Construct

Default value: FALSE


The “tandy-bit” property

  “tandy-bit”                gboolean

Some early Infocom games were sold by the Tandy Corporation. Setting this property to TRUE changes the wording of some Version 3 Infocom games slightly, so as to be less offensive. See http://www.ifarchive.org/if-archive/infocom/info/tandy_bits.html.

Only affects Z-machine interpreters.

Owner: ChimaraIF

Flags: Read / Write / Construct

Default value: FALSE


The “typo-correction” property

  “typo-correction”          gboolean

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.

Only affects Nitfol.

Owner: ChimaraIF

Flags: Read / Write / Construct

Default value: TRUE

Signal Details

The “command” signal

void
user_function (ChimaraIF *self,
               char      *input,
               char      *response,
               gpointer   user_data)

Emitted once for each input-response cycle of an interactive fiction game. Note that games with nontraditional input systems (i.e. not all taking place in the same text buffer window) may confuse this signal.

It may happen that input is NULL, in which case response is not due to a user command, but contains the text printed at the beginning of the game, up until the first prompt.

Parameters

self

The widget that received the signal

 

input

The command typed into the game, or NULL

 

response

The game's response to the command

 

user_data

user data set when the signal handler was connected.