Created
June 19, 2012 00:21
-
-
Save BenLand100/2951612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program default; | |
{$loadlib libsmartremote} | |
procedure GetSmartParams(var root,params: string); | |
var | |
path: String; | |
loc: integer; | |
begin | |
path:= Between('<iframe id="game" src="', '" frameborder', GetPage('http://www.runescape.com/game.ws?j=1')); | |
loc:= pos('runescape.com/',path); | |
root:= Copy(path,0,loc+13); | |
params:= Copy(path,loc+14,length(path)-loc+14); | |
//writeln(root) | |
//writeln(params); | |
end; | |
function GetSmartIDs: TIntegerArray; | |
var | |
i, count: Integer; | |
begin | |
count := SmartGetClients(True); | |
writeln(count); | |
SetLength(Result, count); | |
if count > 0 then | |
for i:= 0 to count-1 do | |
begin | |
Result[i] := SmartClientID(i); | |
writeln(result[i]); | |
end; | |
end; | |
function PairToSmart(id: Integer): boolean; | |
var | |
i, c: Integer; | |
Ids: TIntegerArray; | |
begin | |
Ids := GetSmartIDs; | |
c := Length(Ids); | |
if c > 0 then | |
for i:= 0 to c-1 do | |
if (Ids[i] = id) and SmartPairClient(id) then | |
begin | |
SetEIOSTarget('libsmartremote', ToStr(id)); | |
Writeln('Paired with SMART['+ToStr(id)+']'); | |
Result := True; | |
Exit; | |
end; | |
Writeln('** SMART remote['+ ToStr(id) +'] does not exist **'); | |
end; | |
function InitSmart(force_new: boolean): integer; | |
var | |
i, c: Integer; | |
Ids: TIntegerArray; | |
root,params: string; | |
begin | |
if not force_new then | |
begin | |
writeln('hey'); | |
Ids := GetSmartIDs; | |
writeln('bye'); | |
c := Length(Ids); | |
writeln('sure'); | |
if c > 0 then | |
for i:= 0 to c-1 do | |
begin | |
writeln('pair?'); | |
if SmartPairClient(Ids[i]) then | |
begin | |
writeln('yes'); | |
Result := Ids[i]; | |
SetEIOSTarget('libsmartremote', ToStr(Result)); | |
Writeln('Paired with SMART['+ToStr(Result)+']'); | |
Exit; | |
end; | |
writeln('nope'); | |
end; | |
end; | |
writeln('can has params'); | |
GetSmartParams(root,params); | |
Writeln('Loading SMART: ' + root + params); | |
Result := SmartSpawnClient('./Plugins/', root, params, 765, 503, 's', '', '/usr/lib/jvm/sun-jre-bin-1.6/lib/amd64/server/libjvm.so', -1); | |
if (Result > 0) then SetEIOSTarget('libsmartremote', ToStr(Result)); | |
end; | |
procedure KillAllSmartRemotes; | |
var | |
Ids: TIntegerArray; | |
i: Integer; | |
begin | |
Ids := GetSmartIDs; | |
for i := High(Ids) downto 0 do | |
begin | |
SmartKillClient(Ids[i]); | |
Writeln('Killed SMART['+ToStr(Ids[i])+']'); | |
end; | |
end; | |
function SmartLoaded: boolean; | |
begin | |
Result := (GetColor(10, 10) <> 0); | |
end; | |
procedure SetupSmart; | |
var | |
id, t: Integer; | |
begin | |
t := GetTimeRunning; | |
id := InitSmart(False); | |
if (id = 0) then | |
begin | |
Writeln('** SMART failed to load **'); | |
TerminateScript; | |
end else | |
Writeln('SMART is loading..'); | |
repeat | |
Wait(100); | |
if (GetTimeRunning - t) > 120000 then | |
Break; | |
until(SmartLoaded); | |
Writeln('SMART loaded in ' + ToStr(GetTimeRunning - t) + ' msec'); | |
end; | |
var | |
w,h,bmp: integer; | |
begin | |
SetupSmart; | |
w:= 765; | |
h:= 503; | |
bmp := CreateBitmap(w, h); | |
SetPersistentMemoryBitmap(bmp, SmartDebugArray(), w, h); | |
for x:= 0 to w-1 do | |
for y:= 0 to h-1 do | |
FastSetPixel(bmp,x,y,$00ffff); | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment