|
|
@ -10,6 +10,7 @@ using namespace DFHack;
|
|
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("color-dfhack-text");
|
|
|
|
DFHACK_PLUGIN("color-dfhack-text");
|
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(gps);
|
|
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
bool flicker;
|
|
|
|
bool flicker;
|
|
|
@ -29,44 +30,82 @@ void color_text_tile(const Screen::Pen &pen, int x, int y, bool map)
|
|
|
|
return color_text_hook.next()(pen2, x, y, map);
|
|
|
|
return color_text_hook.next()(pen2, x, y, map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void aaaaa_set_tile(const Screen::Pen &pen, int x, int y, bool map);
|
|
|
|
|
|
|
|
GUI_HOOK_CALLBACK(Screen::Hooks::set_tile, aaaaa_set_tile_hook, aaaaa_set_tile);
|
|
|
|
|
|
|
|
void aaaaa_set_tile(const Screen::Pen &pen, int x, int y, bool map)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Screen::Pen pen2 = pen;
|
|
|
|
|
|
|
|
if ((pen.ch >= 'A' && pen.ch <= 'Z') || (pen.ch >= '0' && pen.ch <= '9'))
|
|
|
|
|
|
|
|
pen2.ch = 'A';
|
|
|
|
|
|
|
|
else if (pen.ch >= 'a' && pen.ch <= 'z')
|
|
|
|
|
|
|
|
pen2.ch = 'a';
|
|
|
|
|
|
|
|
aaaaa_set_tile_hook.next()(pen2, x, y, map);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void shift_set_tile(const Screen::Pen &pen, int x, int y, bool map);
|
|
|
|
|
|
|
|
GUI_HOOK_CALLBACK(Screen::Hooks::set_tile, shift_set_tile_hook, shift_set_tile);
|
|
|
|
|
|
|
|
void shift_set_tile(const Screen::Pen &pen, int x, int y, bool map)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x = (x + 1) % gps->dimx;
|
|
|
|
|
|
|
|
shift_set_tile_hook.next()(pen, x, y, map);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_enable (color_ostream &out, bool enable)
|
|
|
|
DFhackCExport command_result plugin_enable (color_ostream &out, bool enable)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
color_text_hook.apply(enable);
|
|
|
|
color_text_hook.apply(enable);
|
|
|
|
|
|
|
|
if (!enable)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
shift_set_tile_hook.disable();
|
|
|
|
|
|
|
|
aaaaa_set_tile_hook.disable();
|
|
|
|
|
|
|
|
}
|
|
|
|
is_enabled = enable;
|
|
|
|
is_enabled = enable;
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
command_result color(color_ostream &out, std::vector<std::string> ¶ms)
|
|
|
|
command_result color(color_ostream &out, std::vector<std::string> ¶ms)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
plugin_enable(out, true);
|
|
|
|
|
|
|
|
std::string p0 = toLower(params[0]);
|
|
|
|
|
|
|
|
#define CHECK_COLOR(color_name) else if (p0 == toLower(std::string(#color_name))) \
|
|
|
|
|
|
|
|
{ config.flicker = false; config.color = COLOR_##color_name % 8; }
|
|
|
|
|
|
|
|
if (params.empty())
|
|
|
|
if (params.empty())
|
|
|
|
return CR_OK;
|
|
|
|
return plugin_enable(out, true);
|
|
|
|
CHECK_COLOR(RED)
|
|
|
|
for (auto it = params.begin(); it != params.end(); ++it)
|
|
|
|
CHECK_COLOR(GREEN)
|
|
|
|
|
|
|
|
CHECK_COLOR(BLUE)
|
|
|
|
|
|
|
|
CHECK_COLOR(YELLOW)
|
|
|
|
|
|
|
|
CHECK_COLOR(BROWN)
|
|
|
|
|
|
|
|
CHECK_COLOR(CYAN)
|
|
|
|
|
|
|
|
CHECK_COLOR(MAGENTA)
|
|
|
|
|
|
|
|
CHECK_COLOR(WHITE)
|
|
|
|
|
|
|
|
CHECK_COLOR(GREY)
|
|
|
|
|
|
|
|
CHECK_COLOR(BLACK)
|
|
|
|
|
|
|
|
#undef CHECK_COLOR
|
|
|
|
|
|
|
|
else if (p0 == "flicker")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
config.flicker = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (p0 == "disable")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
plugin_enable(out, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (p0 != "enable")
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out.printerr("Unrecognized option: %s\n", p0.c_str());
|
|
|
|
std::string p = toLower(*it);
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
if (!p.size())
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
#define CHECK_COLOR(color_name) else if (p == toLower(std::string(#color_name))) \
|
|
|
|
|
|
|
|
{ config.flicker = false; config.color = COLOR_##color_name % 8; plugin_enable(out, true); }
|
|
|
|
|
|
|
|
CHECK_COLOR(RED)
|
|
|
|
|
|
|
|
CHECK_COLOR(GREEN)
|
|
|
|
|
|
|
|
CHECK_COLOR(BLUE)
|
|
|
|
|
|
|
|
CHECK_COLOR(YELLOW)
|
|
|
|
|
|
|
|
CHECK_COLOR(BROWN)
|
|
|
|
|
|
|
|
CHECK_COLOR(CYAN)
|
|
|
|
|
|
|
|
CHECK_COLOR(MAGENTA)
|
|
|
|
|
|
|
|
CHECK_COLOR(WHITE)
|
|
|
|
|
|
|
|
CHECK_COLOR(GREY)
|
|
|
|
|
|
|
|
CHECK_COLOR(BLACK)
|
|
|
|
|
|
|
|
#undef CHECK_COLOR
|
|
|
|
|
|
|
|
else if (p == "flicker")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
config.flicker = true;
|
|
|
|
|
|
|
|
plugin_enable(out, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (p.size() >= 3 && p.substr(0, 3) == "aaa")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
aaaaa_set_tile_hook.toggle();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (p == "shift")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
shift_set_tile_hook.toggle();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (p == "disable")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
plugin_enable(out, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (p != "enable")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
out.printerr("Unrecognized option: %s\n", p.c_str());
|
|
|
|
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -75,7 +114,7 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
|
|
|
|
{
|
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"color-dfhack-text",
|
|
|
|
"color-dfhack-text",
|
|
|
|
"color <color>|flicker|enable|disable",
|
|
|
|
"color <color>|flicker|enable|disable|shift|aaaaa",
|
|
|
|
color,
|
|
|
|
color,
|
|
|
|
false
|
|
|
|
false
|
|
|
|
));
|
|
|
|
));
|
|
|
|