Merge pull request #1482 from BenLubar/title-folder-text

Don't print an error about not being able to get the SDL title in text mode.
develop
Alan 2020-01-16 10:19:46 -05:00 committed by GitHub
commit 1cd78a2de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

@ -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 <PluginCommand> &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('/');