Results 1 to 6 of 6

Thread: GetChooseOptions TextType parameter unused

  1. #1
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default GetChooseOptions TextType parameter unused

    I was looking into how the TextType parameter (used in Option functions) treat 'action' and 'player', two rather distinct color as the same. And to my surprise, TextType isn't used in the function at all, meaning that no matter what you input as parameter will have no impact at all (you can even put a random string of numbers and not get any error).

    Code below for quick reference.
    Simba Code:
    GetChooseOptions
    ~~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function GetChooseOptions(TextType: string): Array of TOptions;

    Gets the texe from the options menu.

    .. note::

        by Wizzup? & Narcle

    Example:

    .. code-block:: pascal

    *)
    Function GetChooseOptions(TextType: string): Array of TOptions;
    var
       B, BB, sB, BigBox: TBox;
       TPA, TPA1, TPA2: TPointArray;
       ATPA, tempatpa: T2DPointArray;
       I, L, target, bmp,w,h, cts: Integer;
       BoxColors: TIntegerArray;
    begin
      target := GetImageTarget;
      GetClientDimensions(B.X2, B.Y2);
      B := IntToBox(0, 0, B.X2-1, B.Y2-1);
      cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);
      //            Black, Top Blue, grey
      BoxColors := [131843, 3682593, 3552822];
      SetLength(ATPA, Length(BoxColors));
      for i := 0 to High(BoxColors) do
        FindColorsTolerance(ATPA[i], BoxColors[i], B.X1, B.Y1, B.X2, B.Y2, 0);
      TPA := MergeATPA(ATPA);
      If Length(TPA) < 100 Then
      begin
        ColorToleranceSpeed(cts);
        Exit;
      end;

      ATPA := SplitTPA(TPA, 4);
      For i := 0 to High(ATPA) do
      begin
        B := GetTPABounds(ATPA[i]);
        if ((B.x2-B.x1) > 90) and ((B.y2-B.y1) > 18) then
          Break
        else
          B := IntToBox(0, 0, 0, 0);
      end;

      If (B.x2 = 0) then
      begin
        ColorToleranceSpeed(cts);
        Exit;
      end;

      BigBox := B;

      SetColorToleranceSpeed(3);
      FindColorsTolerance(TPA1, 4996381, B.X1, B.Y1, B.X2, B.Y2, 18);//One color covers both Highlighted and non
      sB := GetTPABounds(TPA1);
      ReturnPointsNotInTPAWrap(TPA1, sB, TPA);
      FindColorsTolerance(TPA2, 460291, B.X1, B.Y1, B.X2, B.Y2, 6);//shadow
      SetColorToleranceSpeed(cts);

      bmp := CreateBitmap(B.X2-B.X1+2, B.Y2-B.Y1+2);
      OffsetTPA(TPA, Point(-B.X1, -B.Y1));
      OffsetTPA(TPA2, Point(-B.X1, -B.Y1));
      FastDrawClear(bmp, 0);
      DrawTPABitmap(bmp, TPA, clRed);//Text
      DrawTPABitmap(bmp, TPA2, clPurple);//Shadow
      ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp));
      GetbitmapSize(bmp,w,h);
      SetTargetBitmap(bmp);  // new target for findcolorstolerance.
      SetLength(ATPA, H div 16);
      for i := 0 to High(ATPA) do
        FindColorsTolerance(ATPA[i], clRed, 0, 2+i*16,  W-1, 18+i*16, 0);//+2 to y to line it up
      L := High(ATPA);
      SortATPAFromFirstPointY(ATPA, Point(w div 2,0));

      SetArrayLength(Result, Length(ATPA));
      Result[0].BigBox := BigBox;
      for i := 0 to high(ATPA) do
      begin
        TPA := ATPA[i];
        tempatpa := SplitTPAEx(TPA, 1, 10); // Split one into characters
        SortATPAFromFirstPointX(tempatpa, Point(0, 0));
        Result[i].Str := GetTextATPA(tempatpa, 5, 'UpCharsEx'); //Writeln(Result[i].Str);
        BB := GetTPABounds(ATPA[i]);
        Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
        setlength(tempatpa,0);
        setlength(TPA,0);
      end;
      ColorToleranceSpeed(cts);
      SetImageTarget(target);
      FreeBitmap(bmp);
    end;

    From comments of related functions:
    Simba Code:
    Searches for TextType you input.
    'action', 'player': The white text
    'item': The orange text
    'npc': The yellow text
    'object': The cyan text
    'all': Searches for all colors of text.
    Will default to 'all'.

  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Yeah, this has been like that for a while I think. It's not really a bug, though. The parameter was used in the past, but if we were to remove it now, it would break a lot of scripts, which would be a pain.

    It will be removed for the next version of SRL, though.

  3. #3
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Yeah, this has been like that for a while I think. It's not really a bug, though. The parameter was used in the past, but if we were to remove it now, it would break a lot of scripts, which would be a pain.

    It will be removed for the next version of SRL, though.
    Why was it removed? It could be useful in some situations for more accurate option choosing.

  4. #4
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    I'm not 100% sure because I'm not the only who rewrote the algorithm (I think Narcle did it), but the function used to look for the text color (hence, the parameter) and get a text from that. Some time ago, the choose option menu was updated, and that method proved to be unreliable.

    Now, I think, it finds the menu's background color, then gets text from the points that aren't that color. So basically, it will find all the text in the menu no matter what, rather that a specific type (or color).

    I hope that was clear.

  5. #5
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    I'm not 100% sure because I'm not the only who rewrote the algorithm (I think Narcle did it), but the function used to look for the text color (hence, the parameter) and get a text from that. Some time ago, the choose option menu was updated, and that method proved to be unreliable.

    Now, I think, it finds the menu's background color, then gets text from the points that aren't that color. So basically, it will find all the text in the menu no matter what, rather that a specific type (or color).

    I hope that was clear.
    Correct. They really tried to break our scripts with tons of changes to ChooseOption. It had to be reworked constantly to keep up with it, so finally with Wizzups help I came up with the current one. Hasn't broken yet? (just color change now and then I've seen in SRL git)

    The colors change too much for TextType to be used anymore.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  6. #6
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Thanks for the clarification! While i agree that it may be better to keep the parameter temporary to avoid breaking too many scripts, the comments in the include should at least be edited to communicate the changes.

    Most people may still think TextType works and rely on it to differentiate between different options. I understand that the dev may be too busy with actual coding to be bothered with writing stories...hopefully the situation will improve with more SSRL joining the team

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •