1 /* Dungeon Master --- RPG Adventure Generator
2 Copyright © 2019 Javier Sancho <jsf@jsancho.org>
4 Dungeon Master is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 Dungeon Master is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Dungeon Master. If not, see <http://www.gnu.org/licenses/>.
21 #include "generators.h"
26 SCM register_scene_generator (SCM name, SCM type, SCM proc)
28 SceneGenerator generator {scm_to_locale_string (name), scm_to_locale_string (type), proc };
29 //register_generator (generator);
30 printf ("Register: %s (%s)\n", generator.name.c_str (), generator.type.c_str ());
31 scm_call_1 (proc, scm_from_int (-1));
32 return SCM_UNSPECIFIED;
35 void init_dungeon_master_module (void *unused)
37 scm_c_define_gsubr ("register-scene-generator", 3, 0, 0, (scm_t_subr) register_scene_generator);
38 scm_c_export ("register-scene-generator", NULL);
41 void scm_init_dungeon_master_module ()
43 scm_c_define_module ("dungeon-master", init_dungeon_master_module, NULL);
46 void add_to_load_path (std::string path)
48 // Add path to %load-path variable, needed for modules created in mods
49 std::string exp = "(add-to-load-path \"" + path + "\")";
50 scm_c_eval_string (exp.c_str ());
53 void load_dmaster_mods ()
56 scm_init_dungeon_master_module ();
58 std::set<std::string> paths = get_dmaster_paths ();
65 for (const std::string &path : paths)
67 mods_path = path + PATH_DELIM + "mods";
68 add_to_load_path (mods_path);
69 mods_dir = opendir (mods_path.c_str ());
72 while (mod = readdir (mods_dir))
74 if (strstr (mod->d_name, ".scm") != NULL) {
75 mod_main = mods_path + PATH_DELIM + mod->d_name;
76 scm_primitive_load (scm_from_locale_string (mod_main.c_str ()));