Skip to content

Commit

Permalink
Improve uptext reading with interfaces open
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Jun 24, 2023
1 parent b0716eb commit a1cbe8c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions osr/mainscreen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type
end;

TRSMainScreen = record(TRSInterface)
UpTextBitmapBuffer: TMufasaBitmap;
UpTextArea: TBox;
UpTextFilter: TOCRFilter;

Expand All @@ -154,6 +155,7 @@ procedure TRSMainScreen.Free;
var
Bitmap: Int32;
begin
Self.UpTextBitmapBuffer.Free();
for Bitmap in Self.YellowClicks + Self.RedClicks do
FreeBitmap(Bitmap);
end;
Expand All @@ -175,7 +177,8 @@ begin

Self.Name := 'MainScreen';

Self.UpTextFilter := TOCRAnyColorFilter.Create(85, 60);
Self.UpTextBitmapBuffer.Init(Client.GetMBitmaps());
Self.UpTextFilter := TOCRAnyColorFilter.Create(85, 65);
Self.UpTextFilter.MinCharacterMatch := '-';

Self.YellowClicks := [
Expand Down Expand Up @@ -237,8 +240,16 @@ Example
WriteLn(MainScreen.GetUpText());
*)
function TRSMainScreen.GetUpText(): String;
var
Bitmap: TMufasaBitmap;
begin
Result := OCR.RecognizeStatic(Self.UpTextArea, Self.UpTextFilter, RS_FONT_BOLD_12_SHADOW);
with Self.UpTextArea do
Self.UpTextBitmapBuffer.CopyClientToBitmap(Client.GetIOManager(), True, X1,Y1,X2,Y2);

// improve when bankscreen (and other interfaces) are open
// replace orange title text with interface background color
Self.UpTextBitmapBuffer.ReplaceColor(2070783, 3424329);
Result := OCR._RecognizeStatic(Self.UpTextBitmapBuffer.ToMatrix(), Self.UpTextFilter, RS_FONT_BOLD_12_SHADOW);

{$IFDEF SRL_DEBUG_UPTEXT}
Self.DebugLn('UpText: ' + Result);
Expand Down

0 comments on commit a1cbe8c

Please sign in to comment.