program BitmapBrowser;
const MapName = 'RsMap'; // Name of the bitmap you want to browse.
FormW = 600; // Width of the form.
FormH = 600; // Height of the form.
Xoff = 2382; // No need to change.
Yoff = 2216; // No need to change.
var
MainForm: TForm;
MapForm: TImage;
Button1, Button2: TButton;
Memo: TMemo;
ZoomLabel: TLabel;
MarkTCheck, LineTCheck, ZoomTCheck: TCheckBox;
ZoomScrollBar, WidthBar, HeightBar: TScrollBar;
var
Map, Width, Height, Counter: integer;
CurrentX1, CurrentY1, CurrentX2, CurrentY2: integer;
ZoomPick, MarkIt, Lines: Boolean;
Zoom: Extended;
MarkedSpots: TPointArray;
procedure LoadMap;
begin
Map := LoadBitmap(ScriptPath+MapName+'.bmp');
GetBitmapSize(Map, Width, Height);
end;
procedure FreeMap;
begin
FreeBitmap(Map);
end;
procedure SetSelfWindowState(State:TWindowState); //Yakman
begin
GetSelf.WindowState :=State;
end;
procedure SafeSetSelfWindowState(State:TWindowState); //Yakman
var
t: TVariantArray;
begin
t := [state];
ThreadSafeCall('SetSelfWindowState', t);
end;
procedure UpdateMap(PositionW, PositionH: integer);
begin
CurrentX1 := PositionW
if CurrentX1 < 0 then CurrentX1 := 0;
CurrentY1 := PositionH
if CurrentY1 < 0 then CurrentY1 := 0;
CurrentX2 := CurrentX1 + Round(FormW / Zoom);
CurrentY2 := CurrentY1 + Round(FormH / Zoom);
if CurrentX2 > Width then if Width > FormW then
begin
CurrentX1 := Width - Round(FormW / Zoom);
CurrentX2 := Width;
end;
if CurrentY2 > Height then if Height > FormH then
begin
CurrentY1 := Height - Round(FormH / Zoom);
CurrentY2 := Height;
end;
end;
procedure MarkLines;
var
x1, y1, x2, y2, i: integer;
begin
if GetArrayLength(MarkedSpots) < 1 then Exit;
MapForm.Canvas.Pen.Color := 255;
MapForm.Canvas.Pen.Width := 2;
for i := 1 to GetArrayLength(MarkedSpots) -1 do
begin
x1 := Round((MarkedSpots[i -1].x - CurrentX1) * Zoom);
y1 := Round((MarkedSpots[i -1].y - CurrentY1) * Zoom);
x2 := Round((MarkedSpots[i].x - CurrentX1) * Zoom);
y2 := Round((MarkedSpots[i].y - CurrentY1) * Zoom);
//WriteLn('x1: '+IntTostr(x1)+' y1: '+IntTostr(y1)+' x2: '+IntTostr(x2)+' y2: '+IntToStr(y2));
MapForm.Canvas.MoveTo(x1, y1);
MapForm.Canvas.LineTo(x2, y2);
end;
end;
procedure MarkSpots;
var
i, x1, y1, x2, y2: integer;
begin
MapForm.Canvas.Pen.Color := 255;
MapForm.Canvas.Pen.Width := 2;
for i := 0 to GetArrayLength(MarkedSpots) -1 do
begin
x1 := Round((MarkedSpots[i].x - CurrentX1) * Zoom);
y1 := Round((MarkedSpots[i].y - CurrentY1) * Zoom);
x2 := x1 + 3;
y2 := y1 + 3;
//WriteLn('x1: '+IntTostr(x1)+' y1: '+IntTostr(y1)+' x2: '+IntTostr(x2)+' y2: '+IntToStr(y2));
MapForm.Canvas.RecTangle(x1, y1, x2, y2);
end;
if Lines then MarkLines;
end;
procedure MarkSpotInArray(x, y: integer);
begin
SetArrayLength(MarkedSpots, GetArrayLength(MarkedSpots) +1);
MarkedSpots[GetArrayLength(MarkedSpots) -1].x := Round(x / Zoom) + CurrentX1 -5;
MarkedSpots[GetArrayLength(MarkedSpots) -1].y := Round(y / Zoom) + CurrentY1 -1;
end;
procedure OnScroll(sender: TObject);
begin
UpdateMap(WidthBar.Position, HeightBar.Position);
//WriteLn('CurrentX1: '+IntToStr(CurrentX1)+' CurrentY1: '+IntToStr(CurrentY1)+' CurrentX2: '+IntToStr(CurrentX2)+' CurrentY2: '+IntToStr(CurrentY2));
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;
procedure OnZoomPick(sender: TObject);
begin
if ZoomTCheck.Checked then ZoomPick := True else ZoomPick := False;
end;
procedure OnMarkPoints(sender: TObject);
begin
if MarkTCheck.Checked then MarkIt := True else MarkIt := False;
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
end;
procedure OnMakeLines(sender: TObject);
begin
if LineTCheck.Checked then
begin
Lines := True;
MarkTCheck.Checked := True;
MarkIt := True;
end else Lines := False;
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
end;
procedure SetZoom(sender: TObject);
begin
Zoom := ZoomScrollBar.Position div 10;
//WriteLn('Zoom: '+FloatToStr(Zoom));
UpdateMap(WidthBar.Position, HeightBar.Position);
ZoomLabel.Caption := 'Zoom : '+FloatToStr(Zoom);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;
procedure ClearLast(sender: TObject);
begin
Memo.Lines.Delete(Memo.Lines.Count -1);
Counter := Counter -1;
SetArrayLength(MarkedSpots, GetArrayLength(MarkedSpots) -1);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;
procedure Clear(sender: TObject);
begin
Memo.Lines.Clear;
Counter := 0;
SetArrayLength(MarkedSpots, 0);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
if MarkIt then MarkSpots;
end;
procedure Click(sender: TObject);
var
x, y: integer; Temp: TColor; xx, yy: extended;
begin
if not FindWindowBySize(FormW +11, FormH +251) then WriteLn('Client not found, please restart.');
//FindWindow('Runescape TileFinder - by Nielsie95');
if ZoomPick then PickColor(Temp, x, y) else
GetMousePos(x, y);
MarkSpotInArray(x, y -30);
xx := (Abs(x) / Zoom) + CurrentX1 //+ (Xoff * Zoom);
xx := (xx * 2) div 4;
xx := xx + Xoff//(Xoff * Zoom)
x := Round(xx);
yy := ((Abs(y) -30) / Zoom) + CurrentY1 //+ (Yoff * Zoom);
yy := (yy * 2) div 4;
yy := yy + Yoff//(Yoff * Zoom)
y := Round(yy);
//WriteLn('['+IntTostr(Counter)+'] x: '+IntToStr(x)+' y: '+IntToStr(y)+' TileX: '+IntToStr(x)+' TileY: '+IntToStr(y));
//WriteLn('['+IntTostr(Counter)+'] TileX: '+IntToStr(x)+' TileY: '+IntToStr(y));
Memo.Lines.Add('['+IntTostr(Counter)+'] TileX: '+IntToStr(x)+' TileY: '+IntToStr(y));
Counter := Counter +1;
if MarkIt then MarkSpots;
end;
Procedure InitForm;
begin
MainForm := CreateForm;
MainForm.BorderIcons := [biSystemMenu, biMiniMize];
MainForm.Left := 1573;
MainForm.Top := 129;
MainForm.Width := FormW +10;
MainForm.Height := FormH +250;
MainForm.Caption := 'Runescape TileFinder - by Nielsie95';
MainForm.Color := clBtnFace;
MainForm.Font.Color := clWindowText;
MainForm.Font.Height := -11;
MainForm.Font.Name := 'Arial';
MainForm.Font.Style := [];
MainForm.Visible := False;
MainForm.PixelsPerInch := 96;
MainForm.Position := poScreenCenter;
MapForm := TImage.Create(MainForm);
MapForm.Parent := MainForm;
MapForm.Width := FormW;
MapForm.Height := FormH;
MapForm.Center := True;
MapForm.OnClick := @Click;
WidthBar := TScrollBar.Create(MainForm);
WidthBar.Parent := MainForm;
WidthBar.Top := FormH;
WidthBar.Width := FormW;
WidthBar.Height := 17;
WidthBar.Max := Width;
WidthBar.Position := Width / 2;
WidthBar.TabOrder := 8;
WidthBar.OnChange := @OnScroll;
HeightBar := TScrollBar.Create(MainForm);
HeightBar.Parent := MainForm;
HeightBar.Left := 0;
HeightBar.Top := FormH + 17;
HeightBar.Width := FormW;
HeightBar.Height := 17;
HeightBar.Max := Height;
HeightBar.Position := Height / 2;
HeightBar.TabOrder := 9;
HeightBar.OnChange := @OnScroll;
Memo := TMemo.Create(MainForm);
Memo.Parent := MainForm;
Memo.ScrollBars := ssBoth;
Memo.Left := FormW / 2 - 190;
Memo.Top := FormH + 60;
Memo.Width := 380;
Memo.Height := 100;
Memo.Lines.Add('Runescape TitleFinder - by Nielsie95');
Memo.Lines.Add(' ');
Memo.TabOrder := 10;
ZoomLabel := TLabel.Create(MainForm);
ZoomLabel.Parent := MainForm;
ZoomLabel.Left := FormW / 2 - 110;
ZoomLabel.Top := FormH + 180;
ZoomLabel.Width := 40;
ZoomLabel.Height := 17;
ZoomLabel.Caption := 'Zoom : 1';
ZoomScrollBar := TScrollBar.Create(MainForm);
ZoomScrollBar.Parent := MainForm;
ZoomScrollBar.Left := FormW / 2 -50;
ZoomScrollBar.Top := FormH + 178;
ZoomScrollBar.Width := 120;
ZoomScrollBar.Height := 17;
ZoomScrollBar.PageSize := 0;
ZoomScrollBar.Min := 1;
ZoomScrollBar.Max := 30;
ZoomScrollBar.Position := 10;
ZoomScrollBar.TabOrder := 8;
ZoomScrolLBar.OnChange := @SetZoom;
ZoomTCheck := TCheckBox.Create(MainForm);
ZoomTCheck.Parent := MainForm;
ZoomTCheck.Left := FormW / 2 - 285;
ZoomTCheck.Top := FormH + 65;
ZoomTCheck.Width := 97;
ZoomTCheck.Height := 17;
ZoomTCheck.Caption := 'ZoomPick';
ZoomTCheck.TabOrder := 11;
ZoomTCheck.OnClick := @OnZoomPick;
MarkTCheck := TCheckBox.Create(MainForm);
MarkTCheck.Parent := MainForm;
MarkTCheck.Left := FormW / 2 - 285;
MarkTCheck.Top := FormH + 95;
MarkTCheck.Width := 97;
MarkTCheck.Height := 17;
MarkTCheck.Caption := 'Mark Points';
MarkTCheck.TabOrder := 11;
MarkTCheck.OnClick := @OnMarkPoints;
LineTCheck := TCheckBox.Create(MainForm);
LineTCheck.Parent := MainForm;
LineTCheck.Left := FormW / 2 - 285;
LineTCheck.Top := FormH + 125;
LineTCheck.Width := 97;
LineTCheck.Height := 17;
LineTCheck.Caption := 'Make Route';
LineTCheck.TabOrder := 11;
LineTCheck.OnClick := @OnMakeLines;
Button1 := TButton.Create(MainForm);
Button1.Parent := MainForm;
Button1.Left := FormW / 2 + 207;
Button1.Top := FormH + 75;
Button1.Width := 78;
Button1.Height := 25;
Button1.Caption := 'Clear Debug';
Button1.Font.Color := clWindowText;
Button1.Font.Height := -11;
Button1.Font.Name := 'MS Sans Serif';
Button1.Font.Style := [];
Button1.ParentFont := False;
Button1.TabOrder := 8;
Button1.OnClick := @Clear;
Button2 := TButton.Create(MainForm);
Button2.Parent := MainForm;
Button2.Left := FormW / 2 + 207;
Button2.Top := FormH + 120;
Button2.Width := 78;
Button2.Height := 25;
Button2.Caption := 'Clear Last Line';
Button2.Font.Color := clWindowText;
Button2.Font.Height := -7;
Button2.Font.Name := 'MS Sans Serif';
Button2.Font.Style := [];
Button2.ParentFont := False;
Button2.TabOrder := 9;
Button2.OnClick := @ClearLast;
Zoom := 1;
UpdateMap(Width / 2, Height / 2);
CopyCanvas(GetBitmapCanvas(Map), MapForm.Canvas, CurrentX1, CurrentY1, CurrentX2, CurrentY2, 0, 0, FormW, FormH);
end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
procedure ShowFormModal;
begin
MainForm.ShowModal;
end;
procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
begin
LoadMap;
SafeSetSelfWindowState(wsMinimized);
SafeInitForm;
SafeShowFormModal;
SafeSetSelfWindowState(wsNormal);
FreeForm(MainForm);
FreeMap;
end.
This is the SCAR version I created for KYAB some time ago.
Get the map from Ben's MapCreator and put it in the same map as this script.
Set the mapname and it might work :)