1 #include <glib-object.h>
3 #include <glib/gi18n-lib.h>
5 #include <libpeas/peas.h>
6 #include <libpeas-gtk/peas-gtk.h>
7 #include "chimara-frotz-plugin.h"
8 #include "frotz/frotz.h"
10 typedef struct _ChimaraFrotzPluginPrivate {
12 gboolean random_seed_set;
14 } ChimaraFrotzPluginPrivate;
16 #define CHIMARA_FROTZ_PLUGIN_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), CHIMARA_TYPE_FROTZ_PLUGIN, ChimaraFrotzPluginPrivate))
17 #define CHIMARA_FROTZ_PLUGIN_USE_PRIVATE ChimaraFrotzPluginPrivate *priv = CHIMARA_FROTZ_PLUGIN_PRIVATE(self)
20 static void chimara_frotz_plugin_configurable_init(PeasGtkConfigurableInterface *);
21 static GtkWidget *chimara_frotz_plugin_create_configure_widget(PeasGtkConfigurable *);
23 G_DEFINE_DYNAMIC_TYPE_EXTENDED(ChimaraFrotzPlugin, chimara_frotz_plugin, PEAS_TYPE_EXTENSION_BASE, 0,
24 G_IMPLEMENT_INTERFACE_DYNAMIC(PEAS_GTK_TYPE_CONFIGURABLE, chimara_frotz_plugin_configurable_init));
31 PROP_QUETZAL_SAVE_FORMAT,
33 PROP_EXPAND_ABBREVIATIONS,
36 PROP_TRANSCRIPT_COLUMNS,
41 peas_register_types(PeasObjectModule *module)
43 chimara_frotz_plugin_register_type(G_TYPE_MODULE(module));
44 peas_object_module_register_extension_type(module, PEAS_GTK_TYPE_CONFIGURABLE, CHIMARA_TYPE_FROTZ_PLUGIN);
48 chimara_frotz_plugin_init(ChimaraFrotzPlugin *self)
50 CHIMARA_FROTZ_PLUGIN_USE_PRIVATE;
51 priv->random_seed_set = FALSE;
52 priv->tandy_bit = FALSE;
55 #define PROCESS_FLAG(name) ((flags & (name))? 1 : 0)
58 chimara_frotz_plugin_set_property(GObject *self, unsigned prop_id, const GValue *value, GParamSpec *pspec)
60 CHIMARA_FROTZ_PLUGIN_USE_PRIVATE;
63 case PROP_DEBUG_MESSAGES:
65 unsigned flags = g_value_get_uint(value);
66 option_attribute_assignment = PROCESS_FLAG(CHIMARA_FROTZ_DEBUG_ATTRIBUTE_SETTING);
67 option_attribute_testing = PROCESS_FLAG(CHIMARA_FROTZ_DEBUG_ATTRIBUTE_TESTING);
68 option_object_movement = PROCESS_FLAG(CHIMARA_FROTZ_DEBUG_OBJECT_MOVEMENT);
69 option_object_locating = PROCESS_FLAG(CHIMARA_FROTZ_DEBUG_OBJECT_LOCATING);
70 g_object_notify(self, "debug-messages");
73 case PROP_IGNORE_ERRORS:
74 option_ignore_errors = g_value_get_boolean(value);
75 g_object_notify(self, "ignore-errors");
77 case PROP_PIRACY_MODE:
78 option_piracy = g_value_get_boolean(value);
79 g_object_notify(self, "piracy-mode");
81 case PROP_QUETZAL_SAVE_FORMAT:
82 option_save_quetzal = g_value_get_boolean(value);
83 g_object_notify(self, "quetzal-save-format");
86 priv->tandy_bit = g_value_get_boolean(value);
87 g_object_notify(self, "tandy-bit");
89 case PROP_EXPAND_ABBREVIATIONS:
90 option_expand_abbreviations = g_value_get_boolean(value);
91 g_object_notify(self, "expand-abbreviations");
93 case PROP_RANDOM_SEED:
94 priv->random_seed = g_value_get_int(value);
95 g_object_notify(self, "random-seed");
97 case PROP_RANDOM_SEED_SET:
98 priv->random_seed_set = g_value_get_boolean(value);
99 g_object_notify(self, "random-seed-set");
101 case PROP_TRANSCRIPT_COLUMNS:
102 option_script_cols = g_value_get_uint(value);
103 g_object_notify(self, "transcript-columns");
105 case PROP_UNDO_SLOTS:
106 option_undo_slots = g_value_get_uint(value);
107 g_object_notify(self, "undo-slots");
110 G_OBJECT_WARN_INVALID_PROPERTY_ID(self, prop_id, pspec);
117 chimara_frotz_plugin_get_property(GObject *self, unsigned prop_id, GValue *value, GParamSpec *pspec)
119 CHIMARA_FROTZ_PLUGIN_USE_PRIVATE;
122 case PROP_DEBUG_MESSAGES:
124 unsigned flags = option_attribute_assignment << 0
125 | option_attribute_testing << 1
126 | option_object_movement << 2
127 | option_object_locating << 3;
128 g_value_set_uint(value, flags);
131 case PROP_IGNORE_ERRORS:
132 g_value_set_boolean(value, option_ignore_errors);
134 case PROP_PIRACY_MODE:
135 g_value_set_boolean(value, option_piracy);
137 case PROP_QUETZAL_SAVE_FORMAT:
138 g_value_set_boolean(value, option_save_quetzal);
141 g_value_set_boolean(value, priv->tandy_bit);
143 case PROP_EXPAND_ABBREVIATIONS:
144 g_value_set_boolean(value, option_expand_abbreviations);
146 case PROP_RANDOM_SEED:
147 g_value_set_int(value, priv->random_seed);
149 case PROP_RANDOM_SEED_SET:
150 g_value_set_boolean(value, priv->random_seed_set);
152 case PROP_TRANSCRIPT_COLUMNS:
153 g_value_set_uint(value, option_script_cols);
155 case PROP_UNDO_SLOTS:
156 g_value_set_uint(value, option_undo_slots);
159 G_OBJECT_WARN_INVALID_PROPERTY_ID(self, prop_id, pspec);
164 chimara_frotz_plugin_class_init(ChimaraFrotzPluginClass *klass)
166 GObjectClass *object_class = G_OBJECT_CLASS(klass);
167 object_class->set_property = chimara_frotz_plugin_set_property;
168 object_class->get_property = chimara_frotz_plugin_get_property;
171 g_type_class_add_private(klass, sizeof(ChimaraFrotzPluginPrivate));
175 * ChimaraFrotzPlugin:debug-messages:
177 * Set of flags to control which debugging messages, if any, Frotz prints
178 * while interpreting the story. See #ChimaraFrotzDebugFlags.
180 /* TODO: register a flags type and use g_param_spec_flags() */
181 g_object_class_install_property(object_class, PROP_DEBUG_MESSAGES,
182 g_param_spec_uint("debug-messages", _("Kinds of debugging messages"),
183 _("Control which kinds of debugging messages to print"),
184 0, 255, CHIMARA_FROTZ_DEBUG_NONE,
185 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
187 * ChimaraFrotzPlugin:ignore-errors:
189 * Setting this property to %TRUE will cause the interpreter to ignore
190 * fatal Z-machine runtime errors.
192 g_object_class_install_property(object_class, PROP_IGNORE_ERRORS,
193 g_param_spec_boolean("ignore-errors", _("Ignore errors"),
194 _("Do not warn the user about fatal Z-machine errors"), FALSE,
195 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
197 * ChimaraFrotzPlugin:piracy-mode:
199 * The Z-machine specification defines a facility for games to ask the
200 * interpreter they are running on whether this copy of the game is pirated.
201 * How the interpreter is supposed to magically determine that it is running
202 * pirate software is unclear, and so the majority of games and interpreters
203 * ignore this feature. Set this property to %TRUE if you want the
204 * interpreter to pretend it has detected a pirated game.
206 g_object_class_install_property(object_class, PROP_PIRACY_MODE,
207 g_param_spec_boolean("piracy-mode", _("Piracy mode"),
208 _("Pretend the game is pirated"), FALSE,
209 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
211 * ChimaraFrotzPlugin:quetzal-save-format:
213 * If set to %TRUE, use the newer-style Quetzal format for saved games.
214 * (This is the default.)
216 g_object_class_install_property(object_class, PROP_QUETZAL_SAVE_FORMAT,
217 g_param_spec_boolean("quetzal-save-format", _("Use Quetzal save format"),
218 _("Use the Quetzal format for saved games"), TRUE,
219 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
221 * ChimaraFrotzPlugin:tandy-bit:
223 * Some early Infocom games were sold by the Tandy Corporation. Setting this
224 * property to %TRUE changes the wording of some Version 3 Infocom games
225 * slightly, so as to be less offensive. See <ulink
226 * url="http://www.ifarchive.org/if-archive/infocom/info/tandy_bits.html">
227 * http://www.ifarchive.org/if-archive/infocom/info/tandy_bits.html</ulink>.
229 * Only affects Z-machine interpreters.
231 g_object_class_install_property(object_class, PROP_TANDY_BIT,
232 g_param_spec_boolean("tandy-bit", _("Tandy bit"),
233 _("Censor certain Infocom games"), FALSE,
234 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
236 * ChimaraIF:expand-abbreviations:
238 * Most Z-machine games, in particular ones compiled with the Inform
239 * library, support the following one-letter abbreviations:
241 * <member>D — Down</member>
242 * <member>E — East</member>
243 * <member>G — aGain</member>
244 * <member>I — Inventory</member>
245 * <member>L — Look</member>
246 * <member>N — North</member>
247 * <member>O — Oops</member>
248 * <member>Q — Quit</member>
249 * <member>S — South</member>
250 * <member>U — Up</member>
251 * <member>W — West</member>
252 * <member>X — eXamine</member>
253 * <member>Y — Yes</member>
254 * <member>Z — wait (ZZZZ...)</member>
256 * Some early Infocom games might not recognize these abbreviations.
257 * However, Frotz can expand G, X, and Z regardless of what the game
258 * recognizes. Setting this property to %TRUE will cause Frotz to expand
259 * these abbreviations to the full words before passing the commands on to
262 g_object_class_install_property(object_class, PROP_EXPAND_ABBREVIATIONS,
263 g_param_spec_boolean("expand-abbreviations", _("Expand abbreviations"),
264 _("Expand abbreviations such as X for EXAMINE"), FALSE,
265 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
267 * ChimaraFrotzPlugin:random-seed:
269 * If the #ChimaraFrotzPlugin:random-seed-set property is %TRUE, then the
270 * interpreter will use the value of this property as a seed for the random
271 * number generator. Use this feature to duplicate sequences of random
272 * numbers for testing games.
274 * Note that the value -1 will cause Frotz to pick an arbitrary seed even
275 * when #ChimaraFrotzPlugin:random-seed-set is %TRUE.
277 g_object_class_install_property(object_class, PROP_RANDOM_SEED,
278 g_param_spec_int("random-seed", _("Random seed"),
279 _("Seed for the random number generator"), G_MININT, G_MAXINT, 0,
280 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
282 * ChimaraFrotzPlugin:random-seed-set:
284 * Whether to use or ignore the #ChimaraFrotzPlugin:random-seed property.
286 g_object_class_install_property(object_class, PROP_RANDOM_SEED_SET,
287 g_param_spec_boolean("random-seed-set", _("Random seed set"),
288 _("Whether the seed for the random number generator should be set manually"), FALSE,
289 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
291 * ChimaraFrotzPlugin:transcript-columns:
293 * How many columns to make the transcript output.
295 g_object_class_install_property(object_class, PROP_TRANSCRIPT_COLUMNS,
296 g_param_spec_uint("transcript-columns", _("Transcript columns"),
297 _("Number of columns for transcript output"),
299 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
301 * ChimaraFrotzPlugin:undo-slots:
303 * How many slots to reserve for multiple Undo commands.
305 g_object_class_install_property(object_class, PROP_UNDO_SLOTS,
306 g_param_spec_uint("undo-slots", _("Undo slots"),
307 _("Number of slots to reserve for multiple undo"),
308 0, MAX_UNDO_SLOTS, MAX_UNDO_SLOTS,
309 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS));
313 chimara_frotz_plugin_class_finalize(ChimaraFrotzPluginClass *klass)
318 chimara_frotz_plugin_configurable_init(PeasGtkConfigurableInterface *iface)
320 iface->create_configure_widget = chimara_frotz_plugin_create_configure_widget;
324 chimara_frotz_plugin_create_configure_widget(PeasGtkConfigurable *self)
326 return gtk_label_new("Configure Widget");