MCPcopy Create free account
hub / github.com/DFHack/dfhack / command_result plugin_init

Function command_result plugin_init

plugins/title-folder.cpp:41–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39DFhackCExport command_result plugin_shutdown (color_ostream &out);
40
41DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
42{
43 if (init->display.flag.is_set(init_display_flags::TEXT))
44 {
45 // Don't bother initializing in text mode.
46 return CR_OK;
47 }
48
49 for (auto it = sdl_libs.begin(); it != sdl_libs.end(); ++it)
50 {
51 if ((sdl_handle = OpenPlugin(it->c_str())))
52 break;
53 }
54 if (!sdl_handle)
55 {
56 out.printerr("title-folder: Could not load SDL.\n");
57 return CR_FAILURE;
58 }
59
60 #define bind(name) \
61 _##name = (decltype(_##name))LookupPlugin(sdl_handle, #name); \
62 if (!_##name) { \
63 out.printerr("title-folder: Bind failed: " #name "\n"); \
64 plugin_shutdown(out); \
65 return CR_FAILURE; \
66 }
67
68 bind(SDL_WM_GetCaption);
69 bind(SDL_WM_SetCaption);
70 #undef bind
71
72 const char *title = NULL;
73 SDL_WM_GetCaption(&title, NULL);
74 if (!title)
75 {
76 out.printerr("title-folder: Failed to get original title\n");
77 title = "Dwarf Fortress";
78 }
79 original_title = title;
80
81 return CR_OK;
82}
83
84DFhackCExport command_result plugin_shutdown (color_ostream &out)
85{

Callers

nothing calls this directly

Calls 6

OpenPluginFunction · 0.85
SDL_WM_GetCaptionFunction · 0.85
is_setMethod · 0.80
c_strMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected