@@ -70,11 +70,8 @@ local function GetUnitHappiness(unit)
7070end
7171
7272local function GetUnitJob (unit )
73- local job = unit .job
74- if job and job .current_job then
75- return dfhack .job .getName (job .current_job )
76- end
77- return nil
73+ local job = unit .job .current_job
74+ return job and dfhack .job .getName (job )
7875end
7976
8077local function GetUnitNameAndJob (unit )
169166-- map coordinates -> interface layer coordinates
170167function GetScreenCoordinates (map_coord )
171168 if not map_coord then return end
172-
173169 -- -> map viewport offset
174170 local vp = df .global .world .viewport
175171 local vp_Coord = vp .window_x -- is actually coord
@@ -178,20 +174,25 @@ function GetScreenCoordinates(map_coord)
178174 y = map_coord .y - vp_Coord .y ,
179175 z = map_coord .z - vp_Coord .z ,
180176 }
181- -- -> pixel offset
182- local gps = df .global .gps
183- local map_tile_pixels = gps .viewport_zoom_factor // 4 ;
184- local screen_coord_px = {
185- x = map_tile_pixels * map_offset_by_vp .x ,
186- y = map_tile_pixels * map_offset_by_vp .y ,
187- }
188- -- -> interface layer coordinates
189- local screen_coord_text = {
190- x = math.ceil ( screen_coord_px .x / gps .tile_pixel_x ),
191- y = math.ceil ( screen_coord_px .y / gps .tile_pixel_y ),
192- }
193177
194- return screen_coord_text
178+ if not dfhack .screen .inGraphicsMode () then
179+ return map_offset_by_vp
180+ else
181+ -- -> pixel offset
182+ local gps = df .global .gps
183+ local map_tile_pixels = gps .viewport_zoom_factor // 4 ;
184+ local screen_coord_px = {
185+ x = map_tile_pixels * map_offset_by_vp .x ,
186+ y = map_tile_pixels * map_offset_by_vp .y ,
187+ }
188+ -- -> interface layer coordinates
189+ local screen_coord_text = {
190+ x = math.ceil ( screen_coord_px .x / gps .tile_pixel_x ),
191+ y = math.ceil ( screen_coord_px .y / gps .tile_pixel_y ),
192+ }
193+
194+ return screen_coord_text
195+ end
195196end
196197
197198function TooltipsVizualizer :onRenderFrame (dc , rect )
0 commit comments