Page 1 of 3 123 LastLast
Results 1 to 25 of 71

Thread: 29 Nov. ChooseOption.

  1. #1
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default 29 Nov. ChooseOption.

    I'm pretty much done with the actual text getting, at least with shadows - but that required an enormous effort to create shadows of the fonts. (I did it for most, but next time I'll make sure I do it automatically with a self-written program.

    Anyway.

    • FindText no longer works and neither will FindTextTPA. Therefore I'm using Simba's awesome GetTextATPA.
    • Characters now have (or had, I don't recall) shadow.
    • Font is still SmallChars.
    • Background may be transparent. (Confirm?) Confirmed.
    • Characters have some random spacing. (Confirm?)


    Now, Java is really giving me a bad time, so I'd appreciate some (32 bit) screenshots of various choose option menus. To (specifically) get: The colours used for text, (gray, brown, etc) and test my shadow functions if required. Colours are required to make a non shadow version.

    Here's what I made in 30 mins:

    Simba Code:
    program new;

    var
       bmp, bmp2: integer;
       w, h: integer;
       cts: integer;
       i: integer;

       s: String;

       P: TPointArray;
       ATPA: Array of TPointArray;
       ATPATemp: Array of TPointArray;

    begin

      LoadFont('SmallCharsNS', True);
      LoadFont('SmallCharsNS', False); // we don't really need this.

      bmp := LoadBitmap('chooseopt.bmp');
      SetTargetBitmap(bmp);
      GetClientDimensions(w, h);
      Writeln('Size: ' + inttostr(w) + ', ' + inttostr(h));

      cts := GetToleranceSpeed;
      SetColorToleranceSpeed(1);
      FindColorsTolerance(P, 591618, 0, 0, w-1, h-1, 5); // Find shadows
      // Replace this with multiple FindColorsTolerance + CombineTPA for non-shadow OCR.
      SetColorToleranceSpeed(cts);

      ATPA := SplitTPAEx(P, 15, 2); // Split per line.
      SortATPAFromFirstPoint(ATPA, Point(0,0)); // Sort, SplitTPAEx messes stuff up

      bmp2 := CopyBitmap(bmp);

      writeln(length(atpa));
      DrawATPABitmap(bmp2, ATPA);


      DisplayDebugImgWindow(w, h);
      DrawBitmapDebugImg(bmp2);
      DisplayDebugImgWindow(w, h);

      SaveBitmap(bmp2, 'test.bmp');
      for i := 0 to high(ATPA) do
      begin
        P := ATPA[i];
        ATPATemp := SplitTPAEx(P, 2, 10); // Split one into characters
        SortTPAFrom(P, Point(0, 0)); // Sort SplitTPA messes stuff up
        SortATPAFromFirstPoint(ATPATemp, P[0]); // More Sort

        DrawATPABitmap(bmp2, ATPATemp);

        s := GetTextATPA(ATPATemp, 5, 'SmallCharsNS_s'); // Replace this with 'SmallChars' for non shadow OCR
        writeln(s);
        setlength(atpatemp,0);
        setlength(p,0);
      end;

      SaveBitmap(bmp2, 'test_split.bmp');

      SetDesktopAsClient;
      FreeBitmap(bmp);
    end.

    You need SmallCharsNS in your Fonts: http://wizzup.org/SmallCharsNS.zip (I just added shadows, in the future the shadows will not be required in the bitmaps themselves. (BTW don't use this SmallCharsNS font in combination with BitmapFromText, it will fail)

    So, what do we need to finish this?

    Basically:
    • Retrieve the ChooseOption area
    • Call the above code on it and make it return a string array + position of characters.
    • Call pos() on the string array, return the position of the first hit.


    That's it. The above code can be adjusted to include all the colours and now compare to the SmallChars_NS_s but to SmallChars (no _s), you'll have to FindColorsTolerance() each colour, and combine it into one TPA. Then just call all the same splitstuff etc on it. (IOW Replace the one FindColorsTolerance with several FindColorsTolerance combined with CombineTPA)

    I'd be grateful if someone else could work on this (as well), I'm done for today. I don't know SRL by heart at the moment and I need to focus my time on something else ATM.
    Last edited by Wizzup?; 11-29-2011 at 08:37 PM.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  2. #2
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Obviously, all the SaveBitmap/LoadBitmap/Draw(A)TPABitmap/DisplayDebugImg etc should be removed in the actual inclusion.

    E: Added some comments to the code.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  3. #3
    Join Date
    May 2007
    Location
    Waterloo, Ontario, Canada
    Posts
    1,008
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Looking good Wizzup? Thanks so much for the time you're putting into this... I wish I could be of more help, however, I'm looking at your shadow detection, are you sure that looking around the width/height -1 will do the trick? That MAY need some tinkering, I believe.

    ....Just my two cents.

  4. #4
    Join Date
    Aug 2007
    Location
    Hawaii
    Posts
    3,880
    Mentioned
    7 Post(s)
    Quoted
    152 Post(s)

    Default

    Background is definitely transparent.
    Faith is an oasis in the heart which will never be reached by the caravan of thinking.

  5. #5
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by XxX Toxin XxX View Post
    Looking good Wizzup? Thanks so much for the time you're putting into this... I wish I could be of more help, however, I'm looking at your shadow detection, are you sure that looking around the width/height -1 will do the trick? That MAY need some tinkering, I believe.

    ....Just my two cents.
    Yeah, the 0, 0, w -1, h - 1 is where the chooseoption SHOULD BE. I just had a cropped bitmap to work with. Obviously that will have to be changed. I'm putting it out here in the hope someone else will pick this up and finish it. I think I did the hard part - pretty much any SRL Developer (or scripter probably) can finish this now. I would have made the colours (not shadow) part too, but I didn't have enough screenshots and java keeps messing with me.

    Quote Originally Posted by kingarabian View Post
    Background is definitely transparent.
    How transparent? Would colours ``shine through'' enough to bother the OCR? In that case we'd need a more advanced filter, like the one I use for uptext. (but shadows should still work)



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  6. #6
    Join Date
    Aug 2007
    Location
    Hawaii
    Posts
    3,880
    Mentioned
    7 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Yeah, the 0, 0, w -1, h - 1 is where the chooseoption SHOULD BE. I just had a cropped bitmap to work with. Obviously that will have to be changed. I'm putting it out here in the hope someone else will pick this up and finish it. I think I did the hard part - pretty much any SRL Developer (or scripter probably) can finish this now. I would have made the colours (not shadow) part too, but I didn't have enough screenshots and java keeps messing with me.



    How transparent? Would colours ``shine through'' enough to bother the OCR? In that case we'd need a more advanced filter, like the one I use for uptext. (but shadows should still work)
    Not too transparent... You have to get close up to the screen and squint.
    Faith is an oasis in the heart which will never be reached by the caravan of thinking.

  7. #7
    Join Date
    May 2007
    Location
    Waterloo, Ontario, Canada
    Posts
    1,008
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I think I have came across a weird obscurity.... Check this out guys, I am either going crazy or... I don't know.

    So I'm currently working on a Falador West Miner for mining Iron Ores, and I am looking at the ChooseOption menu. Sometimes there is a different overlay on the opacity of the background. Sometimes when I right-click overtop of a rock, there will be very little overlay of the rock through the menu, however sometimes, when the rock is right-clicked, there is zero overlay of the rocks behind the menu.

    Here's a few sample images :






  8. #8
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    I don't believe that it is transparent enough to shine through.

  9. #9
    Join Date
    Mar 2007
    Location
    USA
    Posts
    1,433
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    There is some transparency, but I think it changes...
    Here are all the images:

    http://alt-f4.co.cc/srl/ (my personal site, the files were too big to attach.







    I'm Silent SPY
    Secret project: 0%
    Need help? Send me a PM

  10. #10
    Join Date
    Aug 2007
    Location
    Hawaii
    Posts
    3,880
    Mentioned
    7 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by XxX Toxin XxX View Post
    I think I have came across a weird obscurity.... Check this out guys, I am either going crazy or... I don't know.

    So I'm currently working on a Falador West Miner for mining Iron Ores, and I am looking at the ChooseOption menu. Sometimes there is a different overlay on the opacity of the background. Sometimes when I right-click overtop of a rock, there will be very little overlay of the rock through the menu, however sometimes, when the rock is right-clicked, there is zero overlay of the rocks behind the menu.

    Here's a few sample images :





    Yeah same here. It's random. I was going crazy around the G.E right clicking everything. Some NPC's can be seen well (but not too well), while some other NPC's were not shown at all.
    Faith is an oasis in the heart which will never be reached by the caravan of thinking.

  11. #11
    Join Date
    May 2007
    Location
    Waterloo, Ontario, Canada
    Posts
    1,008
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by kingarabian View Post
    Yeah same here. It's random. I was going crazy around the G.E right clicking everything. Some NPC's can be seen well (but not too well), while some other NPC's were not shown at all.
    Same thing goes with different ores/rocks. I am seeing a pattern with respect to opacity of the overlay'ed menu. The same rock will only overlay two different ways it appears to me and my imperfect human eyes. It will either have a very vivid opacity, something close to 90(maybe even more), or it will not be visible behind the menu AT all.

  12. #12
    Join Date
    Apr 2007
    Location
    Los Angeles
    Posts
    622
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Thanks for the quick updates Wizzup! Always quick even in the scar days

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

    Default

    Thanks for the pictures. They actually helped

    I have a ChooseOption working but it seems too dodgy then what we want. Will hopefully have it ready tonight.
    (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.

  14. #14
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Guys, watch the option text. The font is constantly moving around, like minimap colors. That's enough to confirm the constant spacing changes.

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

    Default

    Here's new ChooseOption, replace both files (removed) as it has to load shadows on SRL call. If you have Bank problems use Bank.scar attached. (adds additional option to click)

    Noted code changes:

    in Text.scar
    Simba Code:
    Type
      TOptions = Record
        Str: string;
        Bounds: TBox;
      end;  

    Function GetChooseOptions(TextType: string): Array of TOptions;
    var
       B: TBox;
       TPA, TPA1, TPA2: TPointArray;
       aTPA, tempatpa: T2DPointArray;
       I, L: Integer;
       Colors: TIntegerArray;
    begin
      GetClientDimensions(B.X2, B.Y2);
      B.X1 := 0;
      B.Y1 := 0;
      Dec(B.X2);
      Dec(B.Y2);
      FindColorsTolerance(TPA1, 4343893, B.X1, B.Y1, B.X2, B.Y2, 0);
      FindColorsTolerance(TPA2, 3950929, B.X1, B.Y1, B.X2, B.Y2, 0);
      TPA := CombineTPA(TPA1, TPA2);
      If Length(TPA) < 10 Then
        Exit;
      B.X2 := 0;
      B.Y2 := 0;
      aTPA := SplitTPAEx(TPA, 20, 20);
      SortATPASize(aTPA, True);
      B := GetTPABounds(aTPA[0]);

      Colors := [460034];
      SetLength(aTPA, Length(Colors));
      for i := 0 to High(Colors) do
        FindColorsTolerance(aTPA[i], Colors[i], B.X1, B.Y1, B.X2, B.Y2, 5);//yes shadows owns, only 1 color

      TPA := MergeATPA(aTPA);
      aTPA := SplitTPAEx(TPA, 15, 2);
      L := High(aTPA);
      SortATPAFromFirstPoint(ATPA, Point(B.X1, B.y1));

      SetArrayLength(Result, Length(ATPA));
      for i := 0 to high(ATPA) do
      begin
        TPA := ATPA[i];
        tempatpa := SplitTPAEx(TPA, 2, 10); // Split one into characters
        SortTPAFrom(TPA, Point(0, 0)); // Sort SplitTPA messes stuff up
        SortATPAFromFirstPoint(tempatpa, TPA[0]); // More Sort
        Result[i].Str := GetTextATPA(tempatpa, 5, 'SmallCharsNS_s'); // Replace this with 'SmallChars' for non shadow OCR
        Result[i].Bounds := GetTPABounds(ATPA[i]);
        writeln(Result[i].Str);
        setlength(tempatpa,0);
        setlength(TPA,0);
      end;

    end;


    {*******************************************************************************
    function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
    By: Wizzup?, Nava2, and N1ke!
    Description: Finds Popup menu, then clicks on it.
                 Will look for the first string first and so on.
                 It will search for the Text Type you input valid arguments are
                 'action', 'player': The white text
                 'npc': The yellow text
                 'object': The cyan text
                 'all': Searches for all colors of text.
                 Will default to 'all'.
    *******************************************************************************}

    function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
    var
       B: TBox;
       I, H, ii, L: Integer;
       Options: array of TOptions;
    begin
      Result := False;
      Options := GetChooseOptions(TextType);
      H := High(Options);
      L := High(Texts);
      for I := 0 To H do
      begin
        for ii := 0 to L do
          If Pos(Texts[ii], Options[I].Str) > 0 Then
          begin
            Result := True;
            B := Options[I].Bounds;
            case Action of
              ClickLeft: MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5, 1);
              Move:      MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5, 3);
              Nothing:   begin end;
              else
                srl_warn('ChooseOptionMultiEx', 'ClickRight not a valid click for RS menus!', warn_AllVersions);
            end;
            Exit;
          end;
      end;
      if Action <> Nothing then
      begin
        MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
        Wait(200 + Random(100));
      end;

      if (not result) then
        ChooseOptionMultiEx(['Cancel', 'ancel', 'ncel'], 'All', clickLeft);
    end;

    And make sure this is called in SRL.scar

    Simba Code:
    LoadFont('SmallCharsNS', true);
    Last edited by Narcle; 11-29-2011 at 11:41 PM.
    (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.

  16. #16
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Working great and tested thoroughly-ish?
    Commit!?
    Thanks Narcle for the work!

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

    Default

    Quote Originally Posted by YoHoJo View Post
    Working great and tested thoroughly-ish?
    Commit!?
    Thanks Narcle for the work!
    Its not perfect yet. Still shadows missing according to Wizzup. So its just for testing, I'm botting tho lol.

    Edit:
    Wizzup doesn't have time, so going to commit it
    (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.

  18. #18
    Join Date
    Jun 2006
    Posts
    694
    Mentioned
    0 Post(s)
    Quoted
    31 Post(s)

    Default

    Hmm..Was going over transparency this morning....Where's Menu debugger I wrote... >.>


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

    Default

    Commited to svn.

    Make sure your fonts get updated.
    (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.

  20. #20
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Let's find out how stable this first quickfix works.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  21. #21
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Aww yeah!
    At least it's a fix even if a quick one, I'm sure people will continue on working to make it more stable.
    Will test and post here!

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

    Default

    Quote Originally Posted by Wizzup? View Post
    Let's find out how stable this first quickfix works.
    Badly, I did it. duuuh
    (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.

  23. #23
    Join Date
    Jan 2011
    Posts
    121
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wait, so how can I use your fix Narcle? Your attachments weren't working and then they disappeared when I reloaded the page.

  24. #24
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Quote Originally Posted by legoace View Post
    Wait, so how can I use your fix Narcle? Your attachments weren't working and then they disappeared when I reloaded the page.
    Narcle said
    Commited to svn.
    Meaning you can now that them through SRL update.

    My fonts updated on Simba, I think just that will do it.
    But anyways, you should still (In Simba) update your extensions/SRL and it should work now.

  25. #25
    Join Date
    Jan 2011
    Posts
    121
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    you should still (In Simba) update your extensions/SRL and it should work now.
    That's what I thought and did, but SRL banking is still broken (will not choose the option to open the bank). I double-checked by forcing my SRL to update.

Page 1 of 3 123 LastLast

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
  •