Skip to content

Commit 2b52ba2

Browse files
Add a follow offset when spectating units
Closes: #215
1 parent 8fdc2fd commit 2b52ba2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

GUI.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <assert.h>
66
#include <algorithm>
7+
#include <cmath>
78
#include <vector>
89
#include <filesystem>
910
#include <array>
@@ -22,6 +23,7 @@
2223
#include "GameConfiguration.h"
2324
#include "StonesenseState.h"
2425

26+
#include "modules/Screen.h"
2527
#include "modules/Units.h"
2628
#include "DataDefs.h"
2729

@@ -907,6 +909,18 @@ void paintboard()
907909
return;
908910
}
909911

912+
if (df::global::plotinfo->follow_unit != -1) {
913+
if (DFHack::Screen::inGraphicsMode()) {
914+
auto zoom = stonesenseState.ssConfig.zoom;
915+
auto xOff = int(-0.134 * std::pow(zoom, 2) + 2.911 * zoom - 21.214);
916+
stonesenseState.ssConfig.config.viewOffset = { xOff,0,0 };
917+
}
918+
else {
919+
stonesenseState.ssConfig.config.viewOffset = { -46,0,0 };
920+
}
921+
}
922+
923+
910924
segment->DrawAllTiles();
911925

912926
if (ssConfig.config.show_osd) {

0 commit comments

Comments
 (0)