giblorb_map_t *resource_map;
/* File stream pointing to the blorb used as current resource map */
strid_t resource_file;
+ /* Information for opening external blorb file */
+ gboolean open_external_blorb;
+ gchar *external_blorb_pathname;
/* Optional callback for loading resource data */
ChimaraResourceLoadFunc resource_load_callback;
gpointer resource_load_callback_data;
priv->line_input_queue = g_async_queue_new();
/* Should be g_async_queue_new_full(g_free); but only in GTK >= 2.16 */
priv->resource_map = NULL;
+ priv->open_external_blorb = FALSE;
+ priv->external_blorb_pathname = NULL;
priv->resource_lock = g_mutex_new();
priv->resource_loaded = g_cond_new();
priv->resource_info_available = g_cond_new();
if(!result)
return NULL;
}
+
+ /* Open external Blorb file if specified */
+ if(startup->glk_data->open_external_blorb) {
+ glkunix_set_base_file(startup->glk_data->external_blorb_pathname);
+ gchar *basename = g_path_get_basename(startup->glk_data->external_blorb_pathname);
+ frefid_t blorbref = glk_fileref_create_by_name(fileusage_BinaryMode | fileusage_Data, basename, 0);
+ g_free(basename);
+ strid_t blorbfile = glk_stream_open_file(blorbref, filemode_Read, 0);
+ giblorb_set_resource_map(blorbfile);
+ glk_fileref_destroy(blorbref);
+ g_printerr("Opening external blorb file\n");
+ }
/* Run main function */
glk_main_t glk_main = startup->glk_main;
CHIMARA_GLK_USE_PRIVATE(self, glk_priv);
glk_priv->story_name = g_path_get_basename(gamefile);
g_object_notify(G_OBJECT(self), "story-name");
+
+ /* Check if an external blorb file is present */
+ /* FIXME: hardcoded path */
+ if(format == CHIMARA_IF_FORMAT_Z5
+ || format == CHIMARA_IF_FORMAT_Z6
+ || format == CHIMARA_IF_FORMAT_Z8
+ || format == CHIMARA_IF_FORMAT_GLULX) {
+ gchar *path = g_path_get_dirname(gamefile);
+ gchar *scratch = g_path_get_basename(gamefile);
+ *(strrchr(scratch, '.')) = '\0';
+ gchar *blorbfile = g_strconcat(path, "/../Resources/", scratch, ".blb", NULL);
+ if(g_file_test(blorbfile, G_FILE_TEST_EXISTS)) {
+ glk_priv->open_external_blorb = TRUE;
+ glk_priv->external_blorb_pathname = blorbfile;
+ } else {
+ g_free(blorbfile);
+ }
+ g_free(path);
+ g_free(scratch);
+ }
gboolean retval = chimara_glk_run(CHIMARA_GLK(self), pluginpath, argc, argv, error);
g_free(argv);