SRL Archive - SRL Archives

FixGraphics fix


NCDS

2010-02-08 11:16:29

I believe everything is changed that needs to be. I tested and it worked fine.

This sets the graphics mode to "Safe mode" as described by RS mods, Safe Mode is like the old Standard detail mode.



{*******************************************************************************
Procedure FixGraphics;
By: Rasta Magician fixed by TRiLeZ
Rev: 224
Date: 02 Sep 09
Description: Fixes the Graphic Options if LoggedIn
*******************************************************************************}
Procedure FixGraphics;
var
TPA: TPointArray;
TB: TBox;
TP, TP2: TPoint;
i, x, y: integer;
begin
//This procedure is not versatile, just gets the needed job done
if (not LoggedIn) then exit;
CloseWindow;

if (not FindColor(x, y, 0, 7, 460, 69, 474)) then
if (not ClickContinue(True, True)) then
Mouse(MMCX, MMCY, 2, 2, True);

i := 0;
while (not FindTextTPA(2071039, 0, MSX1, MSY1, MSX2, MSY2, 'Graphics Settings', UpChars, Nothing)) and (LoggedIn) do
begin
GameTab(tab_Options);
MouseBox(605, 258, 623, 277, 1);
Wait(1000 + Random(500));
Inc(i);
if (i > 3) then
begin
srl_Warn('SetGraphics', 'Could not open Graphics Options screen', warn_Warning);
CloseWindow;
Exit;
end;
end;

if not (GetColor(160, 82) = SD_Color) then
begin
//Checks for the green arrow, clicks middle of box
Mouse(138, 68, 5, 5, True);
if not WaitColor(160, 82, SD_Color, 0, 2000) then
FixGraphics;
end;

if not (GetColor(157, 156) = Fixed_Color) then
begin
//checks for the yellow color in Fixed Screen sizing
//clicks middle of box
Mouse(168, 138, 5, 5, True);
if not WaitColor(157, 174, Fixed_Color, 0, 2000) then
FixGraphics;
end;

{FindColors(TPA, ScreenSize_Color, ScreenSize_Box_x1,
ScreenSize_Box_y1, ScreenSize_Box_x2,
ScreenSize_Box_y2);

if not (Length(TPA) = ScreenSize_Count) then
begin
//clicks middle of box
Mouse(433, 170, 7, 2, True);
//waits for menu
if WaitColor(475, 162, 8388607, 0, 500) then
Mouse(431, 185, 7, 2, True); //clicks 800x600
end;}

if not (GetColor(235, 199) = Bright_Color) then
begin
//checks for blue ball, clicks Max Brightness
Mouse(235, 199, 3, 3, True);
if not WaitColor(235, 199, Bright_Color, 0, 3000) then
FixGraphics;
end;

//now onto the advanced options
//each box is 15px vertically
//counting from the first layer of brown on top
//and first layer of brown on bottom

for i:= 0 to 5 do //6 options on left column
begin
if FindColor(x, y, WhiteText_Color, 188, 224+16*i, 219, 239+16*i) then
begin
Mouse(188, 224+15*i+7, 40, 3, True); //click middle of box
if WaitColor(188, 224+(16*i), MenuYellow_Color, 0, 1000) then
begin
FindColors(TPA, MenuYellow_Color, 172, 224+16*i, 248, 224+16*i+16*2);
//x - 172 = start of menu ; x - 248 = end of menu
//224+15*i+15*2 = start of menu + 2 options
TB := GetTPABounds(TPA); //--> scar fuck up
if not FindColors(TPA, YellowText_Color, TB.x1, TB.y1, TB.x2, TB.y2) then
writeln(inttostr(Length(TPA)));
TP := MiddleTPA(TPA);
Mouse(TP.x, TP.y, 3, 3, True);
if not WaitColor(188, 224+16*i, MenuBrown_Color, 0, 500+Integer(i=4)*3000) then
FixGraphics;
end else
FixGraphics;
end;
wait(random(500));
end;

for i := 0 to 5 do //6 options on right column
begin
if FindColor(x, y, WhiteText_Color, 437, 208+16*i, 460, 223+16*i) then
begin
Mouse(437, 208+16*i+7, 40, 3, True); //click middle of box
if WaitColor(437, 208+16*i, MenuYellow_Color, 0, 500) then
begin
FindColors(TPA, MenuYellow_Color, 418, 208+16*i, 494, 208+16*i+16*3)
//x - 418 = start of menu ; x - 494 = end of menu
//208+15*i+15*3 = start of menu + 3 options
TB := GetTPABounds(TPA); // --> Scar fuck up.
//TB := IntToBox(418, 208+15*i, 494, 208+15*i+15*2);
FindColors(TPA, YellowText_Color, TB.x1, TB.y1, TB.x2, TB.y2);
TP := Point(418, 208+16*i);
SortTPAFrom(TPA, TP); //all this TPA manipulation is needed because
TP := TPA[0]; //animations have 3 options, while the others have 2
TP2 := MiddleTPA(TPA);
Mouse(TP2.x, TP.y+3, 3, 3, True);
if not WaitColor(188, 224+15*i, MenuBrown_Color, 0, 5000) then
FixGraphics;
end else FixGraphics;
wait(random(500));
end;
end;
Mouse(491, 22, 2, 2, True); //CloseWindow;
end;
I just needed to update some coords in the one above.


This should be placed in Gametab.scar as the color when logged out is different than the color when logged in for the green check mark.

SM_Color = 3721285;
and this would be the new Login_SetGraphics located in Login.scar:

procedure Login_SetGraphics(Brightness: Integer);
var
T, x, y, tx, ty, GraphicsMask, i: Integer;
P: TPoint;
begin
if (LoggedIn) then Exit;
GraphicsMask := BitmapFromString(20, 8, 'beNpjYPiPBBiQwH9UgFUcmYumA' +
'JOLJoipGNMNuMwkQy8eR+LRi1U7JhuPdvx2YXUYZvgQExdYtTAAAF' +
'Km3SM=');
TypeByte(vk_Escape); //347, 273, 393, 292
T := GetSystemTime;
while (not(FindBitmapMaskTolerance(GraphicsMask, X, Y, 279, 272, 483, 352, 0, 0))) and (GetSystemTime - T < 5000) do
Wait(100);
if (FindBitmapMaskTolerance(GraphicsMask, X, Y, 279, 272, 483, 352, 0, 0)) then
Mouse(X - 20, Y + 3, 50, 5, True)
else
begin
FreeBitmap(GraphicsMask);
Exit;
end;
Wait(100);
if not (GetColor(282, 177) = SM_Color) then
for i := 0 to 2 do
begin
//Checks for the green arrow, clicks middle of box
Mouse(260, 162, 5, 5, True);
if WaitColor(282, 177, SM_Color, 0, 2000) then
Break;
if i = 2 then
begin
srl_Warn('SetGraphics', 'Failed to select Safe Mode', warn_Warning);
Exit;
end;
end;
if (Brightness > 4) then
srl_Warn('Login_SetGraphics', 'Brightness must be between 0 and 4', warn_AllVersions)
else
if (Brightness <> 0) then
begin
x := 0;
repeat
P := Point(262 + (Brightness - 1) * 32, 310);
if (GetColor(P.x, P.y) <> 16683152) then
begin
Mouse(P.x - 2, P.y, 3, 3, True);
if WaitColor(P.x, P.Y, 16683152, 1, 1000) then
break;
Inc(x);
end else
break;
until(x >= 5)
end;
repeat
if FindColor(x, y, 16777215, 143, 287, 621, 429) then
begin
Mouse(x + 10, y + 3, 10, 7, True);
getmousepos(tx, ty);
mouse(tx, ty + 10, 4, 4, true);
wait(300);
end;
until(not(FindColor(x, y, 16777215, 143, 287, 621, 429)));
Wait(100);
TypeByte(vk_Escape);
FreeBitmap(GraphicsMask);
end;

Like I said, currently this is only good for making sure you are in Safe mode before starting a script. If you aren't, and the script has to select safe mode for you, it will lose the Client.

Naum

2010-02-08 11:41:10

The only problem is that, are you sure that it still works after setting safe-mode, as the runescape handle could change, causing you to lose active 'ness' of the client.

Looks good btw :)

NCDS

2010-02-08 12:19:50

I only tested the function it self, not inside another script or anything.

I will, then I'll post what if it still works or not..

Gu3st...

2010-02-08 12:21:39

You would want to set it to Safe Mode by the way. Check the thread in RS has been updated for the differences :)

NCDS

2010-02-08 12:33:57

From: Zyt3x
You would want to set it to Safe Mode by the way. Check the thread in RS has been updated for the differences :)


That's what this update is ;)
It does set/make sure you are set to SafeMode.

However, as Naum posted the RS handle changes when you switch to SafeMode so you will need to already be in safemode to be able to auto. This will just make sure you are.

Gu3st...

2010-02-08 12:39:26

From: NCDS
That's what this update is ;)
It does set/make sure you are set to SafeMode.

However, as Naum posted the RS handle changes when you switch to SafeMode so you will need to already be in safemode to be able to auto. This will just make sure you are.
Ah, okay :p
Just making sure

Wanted

2010-02-08 18:40:30

This only works if it's already in safe mode.

NCDS

2010-02-08 19:49:12

From: IceFire908
This only works if it's already in safe mode.


From: NCDS
That's what this update is ;)
It does set/make sure you are set to SafeMode.

However, as Naum posted the RS handle changes when you switch to SafeMode so you will need to already be in safemode to be able to auto. This will just make sure you are.

;)

There's really no other way to do it that I know of..?

Wanted

2010-02-08 19:52:21

From: NCDS
;)

There's really no other way to do it that I know of..?


  {$IFNDEF SRL_SMART}
FindWindowBySize(766, 504);
Wait(500 + Random(250));
ActivateClient;
Wait(500 + Random(250));
{$ENDIF}

Would be good if this could at least switch from standard and HD (fixed) to safe mode, though I'm not exactly how sure all this would work.

NCDS

2010-02-08 19:55:50

From: IceFire908
  {$IFNDEF SRL_SMART}
FindWindowBySize(766, 504);
Wait(500 + Random(250));
ActivateClient;
Wait(500 + Random(250));
{$ENDIF}

Would be good if this could at least switch from standard and HD (fixed) to safe mode, though I'm not exactly how sure all this would work.


It switches it fine (unless something has changed since this morning, which I will look into right now) the only problem was losing the client after switching.

I don't know about the bit you posted however, I tried a simple ActivateClient earlier and it hadn't worked but I'll mess with it a little now.



Edit: yeah it still sets Safe mode fine for me, just then loses the client still ofc.

Wanted

2010-02-08 20:02:28

From: NCDS
It switches it fine (unless something has changed since this morning, which I will look into right now) the only problem was losing the client after switching.

I don't know about the bit you posted however, I tried a simple ActivateClient earlier and it hadn't worked but I'll mess with it a little now.


ActivateClient alone would not work because

1) You could be using SMART, and it's unneeded alltogether.
2) You loose the current handle, so it doesn't know what to activate.

So you need {$DEFINE ect… and FindWindowBySize to get the new handle and activate (if not smart) I'm guessing the reason it doesn't work atm with switching is because the colors are different in SM, SD, and HD for the cords you are using.

NCDS

2010-02-08 20:05:07

From: IceFire908
ActivateClient alone would not work because

1) You could be using SMART, and it's unneeded alltogether.
2) You loose the current handle, so it doesn't know what to activate.

So you need {$DEFINE ect… and FindWindowBySize to get the new handle and activate (if not smart) I'm guessing the reason it doesn't work atm with switching is because the colors are different in SM, SD, and HD for the cords you are using.


I just tried it in Standard Detail and it switched to Safe mode perfectly fine.

I'll start messing with ways to find the client again I suppose..

NCDS

2010-02-08 21:04:28

Ok I have the Login_SetGraphics working fine now and am starting to work with re-activating the client now. However, when using SMART if you are not already in Safe mode, nothing works therefor I believe if you plan to use SMART you will need to set Safe mode before hand.

I'll continue messing with a non SMART fix now..

Wanted

2010-02-08 21:08:05

From: NCDS
Ok I have the Login_SetGraphics working fine now and am starting to work with re-activating the client now. However, when using SMART if you are not already in Safe mode, nothing works therefor I believe if you plan to use SMART you will need to set Safe mode before hand.

I'll continue messing with a non SMART fix now..


Hmmm….

For SMART it might just be best to do

{$IFNDEF SRL_SMART}
FindWindowBySize(766, 504);
Wait(500 + Random(250));
ActivateClient;
Wait(500 + Random(250));
{$ELSE}
WriteLn('Warning! Please restart SMART in RuneScape Safe Mode!');
TerminateScript;
{$ENDIF}

Sir R. M8gic1an

2010-02-08 21:14:22


GetClientDimensions(x, y);
if (x = HD_X)and(y = HD_Y) then
Mode := HD
else if (x = SM_X)and(y = SM_Y) then
Mode := SM
else
Mode := SD;

case Mode of
HD: Params := [.......];
SD: Params := [.......];
SM: Params := [.......];
end;

About how to refind it… Icefire's way seems to be the best so far, can't really think of any other atm.

~RM

NCDS

2010-02-08 21:20:13

From: Rasta Magician

GetClientDimensions(x, y);
if (x = HD_X)and(y = HD_Y) then
Mode := HD
else if (x = SM_X)and(y = SM_Y) then
Mode := SM
else
Mode := SD;

case Mode of
HD: Params := [.......];
SD: Params := [.......];
SM: Params := [.......];
end;

So you want it to be able to select any Graphics level? I was under the impression that we were just going to use Safe mode for autoing?


About how to refind it… Icefire's way seems to be the best so far, can't really think of any other atm.

I'm still working on that :/

Edit: I don't think loading any other Graphics level in SMART is going to work even if we try and change the setting at login. The screen stays flashing and SCAR can't seem to do anything about it :/

I'm going to update the first post with what I have right now which is everything working except for re-targeting the client.

Sabzi

2010-02-09 09:40:24

When I start smart not in sd(or sm now) I can do whatever I want. It's just flashing a bit but you can set the graphics to sm. I haven't tried it with a script just by hand however. So maybe blind coordinate clicking? Or smart not even works when flashing? I never had those problems but I read that mouse not working in it(by script).

NCDS

2010-02-09 10:32:19

From: Sabzi
When I start smart not in sd(or sm now) I can do whatever I want. It's just flashing a bit but you can set the graphics to sm. I haven't tried it with a script just by hand however. So maybe blind coordinate clicking? Or smart not even works when flashing? I never had those problems but I read that mouse not working in it(by script).


That's what I meant was that because of the flashing the script wouldn't work. Me and Icefire have been discussing alternatives and I'll try and see what I can do today.

Bad Boy JH

2010-02-09 21:04:09

now whilst I am not an expert on SMART, what about restarting Smart, after we set it to safe mode, that would at least get smart working…

NCDS

2010-02-09 23:31:53

From: Bad Boy JH
now whilst I am not an expert on SMART, what about restarting Smart, after we set it to safe mode, that would at least get smart working…


Hmm.. I will mess with that idea and see what happens.

Thanks for the suggestion. Though, I'm not sure how that would sit with the Dev's, having to load SMART twice..

Bad Boy JH

2010-02-10 05:49:27

Until such a time as we have an alternate solution, I think its a good idea…

Sabzi

2010-02-10 06:28:36

From: Bad Boy JH
Until such a time as we have an alternate solution, I think its a good idea…


Much better then just terminating the script. So I would say do that.

NCDS

2010-02-10 12:40:25

I will talk with Dev's about it but for now, just make sure your in Safemode beforehand if you plan to auto.