forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer-msg.cpp
58 lines (49 loc) · 1.46 KB
/
renderer-msg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "Console.h"
#include "Core.h"
#include "DataDefs.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Screen.h"
#include "modules/Renderer.h"
#include "df/enabler.h"
#include "df/renderer.h"
//#include "df/world.h"
using namespace DFHack;
DFHACK_PLUGIN("renderer-msg");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(enabler);
REQUIRE_GLOBAL(gps);
struct scdata {
uint8_t ch, fg, bg, bold;
};
struct renderer_msg : public Renderer::renderer_wrap {
virtual void update_tile (int32_t x, int32_t y) {
static std::string str = std::string("DFHack: ") + plugin_name + " active";
Screen::paintString(Screen::Pen(' ', 9, 0), 0, gps->dimy - 1, str);
for (size_t i = 0; i < gps->dimx; ++i)
((scdata*)screen)[i * gps->dimy + gps->dimy - 1].bg = 2;
renderer_wrap::update_tile(x, y);
};
};
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{
return CR_OK;
}
static Renderer::renderer_wrap *w = NULL;
DFhackCExport command_result plugin_enable (color_ostream &out, bool enable)
{
if (is_enabled == enable)
return CR_OK;
CoreSuspender s;
is_enabled = enable;
if (enable)
w = Renderer::AddRenderer(new renderer_msg, true);
else
Renderer::RemoveRenderer(w);
return CR_OK;
}
DFhackCExport command_result plugin_shutdown (color_ostream &out)
{
plugin_enable(out, false);
return plugin_enable(out, false);
}