2012-08-17 12:40:53 -06:00
|
|
|
#include "Core.h"
|
|
|
|
#include <Console.h>
|
|
|
|
#include <Export.h>
|
|
|
|
#include <PluginManager.h>
|
|
|
|
#include <modules/Gui.h>
|
2012-08-18 23:31:09 -06:00
|
|
|
#include <modules/Screen.h>
|
2012-08-17 12:40:53 -06:00
|
|
|
#include <vector>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <stack>
|
|
|
|
#include <string>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <VTableInterpose.h>
|
|
|
|
#include "df/graphic.h"
|
|
|
|
#include "df/viewscreen_titlest.h"
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using std::stack;
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
using df::global::gps;
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("vshook");
|
|
|
|
|
2013-09-30 03:19:51 -06:00
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
|
2012-08-17 12:40:53 -06:00
|
|
|
struct title_hook : df::viewscreen_titlest {
|
|
|
|
typedef df::viewscreen_titlest interpose_base;
|
|
|
|
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, render, ())
|
|
|
|
{
|
|
|
|
INTERPOSE_NEXT(render)();
|
|
|
|
|
2012-08-18 23:31:09 -06:00
|
|
|
Screen::Pen pen(' ',COLOR_WHITE,COLOR_BLACK);
|
|
|
|
Screen::paintString(pen,0,0,"DFHack " DFHACK_VERSION);
|
2012-08-17 12:40:53 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(title_hook, render);
|
|
|
|
|
2013-09-30 03:19:51 -06:00
|
|
|
DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable)
|
2012-08-17 12:40:53 -06:00
|
|
|
{
|
2013-09-30 03:19:51 -06:00
|
|
|
if (!gps)
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
|
|
|
if (enable != is_enabled)
|
2012-08-17 12:40:53 -06:00
|
|
|
{
|
2013-09-30 03:19:51 -06:00
|
|
|
if (!INTERPOSE_HOOK(title_hook, render).apply(enable))
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
|
|
|
is_enabled = enable;
|
2012-08-17 12:40:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-30 03:19:51 -06:00
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
// DON'T DO THIS IN NON-EXAMPLE PLUGINS
|
|
|
|
plugin_enable(out, true);
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-17 12:40:53 -06:00
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
|
|
|
{
|
2012-08-18 01:48:07 -06:00
|
|
|
INTERPOSE_HOOK(title_hook, render).remove();
|
2012-08-17 12:40:53 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|