From cbf5c5459aca2fbf41523fa142966b12e77b4ce1 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Wed, 15 Jan 2020 16:07:41 -0600 Subject: [PATCH] Don't print an error about not being able to get the SDL title in text mode. --- plugins/title-folder.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/title-folder.cpp b/plugins/title-folder.cpp index eae381b95..4f93a6c7f 100644 --- a/plugins/title-folder.cpp +++ b/plugins/title-folder.cpp @@ -5,11 +5,16 @@ #include "MemAccess.h" #include "PluginManager.h" +#include "df/init.h" + using namespace DFHack; +using namespace df::enums; DFHACK_PLUGIN("title-folder"); DFHACK_PLUGIN_IS_ENABLED(is_enabled); +REQUIRE_GLOBAL(init); + // SDL frees the old window title when changed static std::string original_title; @@ -36,6 +41,12 @@ DFhackCExport command_result plugin_shutdown (color_ostream &out); DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { + if (init->display.flag.is_set(init_display_flags::TEXT)) + { + // Don't bother initializing in text mode. + return CR_OK; + } + for (auto it = sdl_libs.begin(); it != sdl_libs.end(); ++it) { if ((sdl_handle = OpenPlugin(it->c_str()))) @@ -92,6 +103,12 @@ DFhackCExport command_result plugin_enable (color_ostream &out, bool state) if (state) { + if (init->display.flag.is_set(init_display_flags::TEXT)) + { + out.printerr("title-folder: cannot enable with PRINT_MODE:TEXT.\n"); + return CR_FAILURE; + } + std::string path = Core::getInstance().p->getPath(); std::string folder; size_t pos = path.find_last_of('/');