-
Notifications
You must be signed in to change notification settings - Fork 30
/
zoomfix.hpp
71 lines (53 loc) · 2.5 KB
/
zoomfix.hpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
static void fix_zoom()
{
if (df::global::cursor->x == -30000)
return;
renderer_cool *r = (renderer_cool*)enabler->renderer;
*df::global::window_x = std::max(0, std::min(world->map.x_count - r->gdimxfull, df::global::cursor->x - r->gdimx / 2));
*df::global::window_y = std::max(0, std::min(world->map.y_count - r->gdimyfull, df::global::cursor->y - r->gdimy / 2));
}
struct viewscreen_unitlistst_zoomfix : public df::viewscreen_unitlistst
{
typedef df::viewscreen_unitlistst interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input))
{
int oldcx = df::global::cursor->x, oldcy = df::global::cursor->y;
bool zooming = false;
if (input->count(interface_key::UNITJOB_ZOOM_CRE) || input->count(interface_key::UNITJOB_ZOOM_BUILD))
zooming = true;
INTERPOSE_NEXT(feed)(input);
if (zooming && (df::global::cursor->x != oldcx || df::global::cursor->y != oldcy))
fix_zoom();
}
};
IMPLEMENT_VMETHOD_INTERPOSE(viewscreen_unitlistst_zoomfix, feed);
struct viewscreen_buildinglistst_zoomfix : public df::viewscreen_buildinglistst
{
typedef df::viewscreen_buildinglistst interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input))
{
int oldcx = df::global::cursor->x, oldcy = df::global::cursor->y;
bool zooming = false;
if (input->count(interface_key::BUILDINGLIST_ZOOM_T) || input->count(interface_key::BUILDINGLIST_ZOOM_Q))
zooming = true;
INTERPOSE_NEXT(feed)(input);
if (zooming && (df::global::cursor->x != oldcx || df::global::cursor->y != oldcy))
fix_zoom();
}
};
IMPLEMENT_VMETHOD_INTERPOSE(viewscreen_buildinglistst_zoomfix, feed);
struct viewscreen_layer_unit_relationshipst_zoomfix : public df::viewscreen_layer_unit_relationshipst
{
typedef df::viewscreen_layer_unit_relationshipst interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input))
{
int oldcx = df::global::cursor->x, oldcy = df::global::cursor->y;
bool zooming = false;
if (input->count(interface_key::UNITVIEW_RELATIONSHIPS_ZOOM))
zooming = true;
INTERPOSE_NEXT(feed)(input);
if (zooming && (df::global::cursor->x != oldcx || df::global::cursor->y != oldcy))
fix_zoom();
}
};
IMPLEMENT_VMETHOD_INTERPOSE(viewscreen_layer_unit_relationshipst_zoomfix, feed);