| 39 | DFhackCExport command_result plugin_shutdown (color_ostream &out); |
| 40 | |
| 41 | DFhackCExport 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 | |
| 84 | DFhackCExport command_result plugin_shutdown (color_ostream &out) |
| 85 | { |
nothing calls this directly
no test coverage detected