@@ -130,7 +130,7 @@ begin
130130
131131 win := win.GetRootWindow();
132132 with win.GetBounds() do
133- win.SetBounds([X1, Y1, X2, Y1+535]);
133+ win.SetBounds([X1, Y1, X2-1 , Y1+535]);
134134 Result := [x1, 0, x2, 503];
135135 end
136136 else
@@ -327,6 +327,43 @@ begin
327327end;
328328
329329
330+ function TRSClient.GetTooltipBounds(): TBox;
331+ var
332+ pt: TPoint;
333+ bounds: TBox;
334+ tpa: TPointArray;
335+ begin
336+ pt := Target.MouseXY;
337+ bounds := Self._Bounds();
338+
339+ if not bounds.Contains(pt) then
340+ Exit;
341+
342+ if pt.Y+43 > bounds.Y2 then
343+ begin
344+ bounds.Y1 := bounds.Y2 - 22;
345+ bounds.Y2 := bounds.Y2 - 3;
346+ end
347+ else
348+ begin
349+ bounds.Y1 := pt.Y + 24;
350+ bounds.Y2 := pt.Y + 43;
351+ end;
352+
353+ tpa := Target.FindColor(TEXT_SHADOW, 0, bounds);
354+ if tpa = [] then
355+ Exit;
356+
357+ tpa := tpa.Cluster(8,4).SortFromFirstPointX(pt).First;
358+ with tpa.Bounds() do
359+ begin
360+ bounds.X1 := Max(X1-6, 0);
361+ bounds.X2 := X2+4;
362+ end;
363+ ShowOnTarget(bounds);
364+ Result := bounds;
365+ end;
366+
330367(*
331368## RSClient.ReadTooltip
332369```pascal
@@ -341,35 +378,20 @@ WriteLn RSClient.ReadTooltip();
341378*)
342379function TRSClient.ReadTooltip(): String;
343380var
344- pt: TPoint;
345- b: TBox;
346- tpa: TPointArray;
381+ bounds: TBox;
347382 font: ^TPixelFont;
348383begin
349- if Self.Client <> ERSClient.OFFICIAL then
350- Exit;
351-
352- pt := Target.MouseXY;
353- with Self._Bounds() do
354- begin
355- if not Contains(pt) then
356- Exit;
357- b := [Max(X1, pt.X)+4, Max(Y1, pt.Y+24)+5, X2, Min(Y2, pt.Y + 45)];
358- end;
359-
360- tpa := Target.FindColor(TEXT_SHADOW, 0, b);
361- if tpa = [] then
362- Exit;
363-
364- tpa := tpa.Cluster(6,4).SortFromFirstPointX(pt).First;
365- b.X2 := tpa.Bounds().X2;
366-
367384 case Self.Client of
368385 ERSClient.OFFICIAL: font := @RSFonts.PLAIN_12;
369386 ERSClient.RUNELITE: font := @RSFonts.SMALL;
387+ else Exit;
370388 end;
371389
372- Result := OCR.RecognizeShadow(b, font^, 0);
390+ bounds := Self.GetTooltipBounds();
391+ if bounds = Default(TBox) then
392+ Exit;
393+
394+ Result := OCR.RecognizeShadow(bounds, font^, 0);
373395end;
374396
375397
0 commit comments