1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-22 01:02:17 -05:00
Simba/Extensions/srl.sex

109 lines
3.2 KiB
Plaintext
Raw Normal View History

2010-04-16 10:08:41 -04:00
program SRLUpdater;
{.INCLUDE ..\Extensions\Updater.sei}
2010-04-16 10:08:41 -04:00
function CheckSRL(Name: string; I: integer): boolean;
2010-04-16 10:08:41 -04:00
var
X: integer;
2010-04-16 10:08:41 -04:00
begin
Result := True;
for X := 0 to Length(UpdaterArr) do
if (UpdaterArr[X].Name = 'Plugins') then
2010-07-15 20:10:01 -04:00
begin
if (Name = 'Check') then
Tick(UpdaterArr[X].CheckMenuItem)
else
Tick(UpdaterArr[X].Timer);
Exit;
2010-07-15 20:10:01 -04:00
end;
2010-07-15 11:42:48 -04:00
end;
procedure OpenDefScript(Sender: TObject);
2010-07-15 11:42:48 -04:00
var
Script: TStringArray;
2010-07-15 11:42:48 -04:00
begin
SetLength(Script, 6);
Script[0] := 'program Untitled;';
Script[1] := '//{$DEFINE SMART} //Uncomment for SMART';
Script[2] := '{.include SRL/SRL.scar}';
if (TMenuItem(Sender).Parent.Caption = 'Reflection') then
2010-07-15 11:42:48 -04:00
begin
SetLength(Script, 7);
Script[1] := '{$DEFINE SMART}';
Script[3] := '{.include Reflection/Reflection.scar}';
2010-07-15 11:42:48 -04:00
end;
Script[Length(Script) - 3] := '';
Script[Length(Script) - 2] := 'begin';
Script[Length(Script) - 1] := 'end.';
2010-07-15 11:42:48 -04:00
WriteLn('Opening ' + TMenuItem(Sender).Parent.Caption + ' Default Script...');
OpenScript('', Implode({$IFDEF WIN}#13+{$ENDIF}#10, Script), False);
2010-04-16 10:08:41 -04:00
end;
function OpenDefMenu(const Blank: string; const ID: integer): boolean;
2010-04-16 10:08:41 -04:00
var
OpenMenuItem: TMenuItem;
2010-04-16 10:08:41 -04:00
begin
OpenMenuItem := MoveMenuItem(UpdaterArr[ID].MainMenu, GetIndex(UpdaterArr[ID].MainMenu, GetMenuByName('Open', UpdaterArr[ID].MainMenu)), GetIndex(UpdaterArr[ID].MainMenu, GetMenuByName('Update', UpdaterArr[ID].MainMenu)));
OpenMenuItem.OnClick := @OpenDefScript;
OpenMenuItem.Visible := True;
2010-04-16 10:08:41 -04:00
end;
function BeforePlugins(NotNeeded: string; I: integer): boolean;
2010-04-16 10:08:41 -04:00
begin
Result := ForceDirectories(UpdaterArr[I].Folder);
2010-04-16 10:08:41 -04:00
end;
2010-07-15 20:10:01 -04:00
function SuccessPlugins(Cont: string; I: integer): boolean;
var
X: integer;
Files: TStringArray;
Overwrite: boolean;
2010-04-16 10:08:41 -04:00
begin
Files := GetFiles(UpdaterArr[I].Folder, {$IFDEF WIN}'dll'{$ELSE}'so'{$ENDIF});
Overwrite := True;
for X := 0 to High(Files) do
if (FileExists(PluginPath + Files[X])) then
2010-07-15 11:42:48 -04:00
begin
Overwrite := (MessageDlg('SRL Updater', 'Do you want to overwrite the plugins?', mtConfirmation, [mbNo, mbYes], 0) = mrYes);
Break;
2010-07-15 11:42:48 -04:00
end;
Result := UnTarEx(Cont, PluginPath, Overwrite);
2010-04-16 10:08:41 -04:00
end;
procedure Init;
var
SRL, Plugins, Refl: integer;
2010-04-16 10:08:41 -04:00
begin
if (AddUpdater('SRL', 'http://wizzup.org/static/srl/srl.tar.bz2', 'http://wizzup.org/static/srl/srl_version', IncludePath, True, True, SRL)) then
begin
UpdaterArr[SRL].Hooks[CHECK_FOR_UPDATE] := @CheckSRL;
UpdaterArr[SRL].Hooks[ATTACH_HOOK] := @OpenDefMenu;
end;
if (AddUpdater('Plugins', 'http://wizzup.org/static/srl/simba_plugins.tar.bz2', 'http://wizzup.org/static/srl/plugins_version', IncludePath + 'SRL/SimbaPlugins/', False, False, Plugins)) then
begin
UpdaterArr[Plugins].Hooks[BEFORE_UPDATE] := @BeforePlugins;
UpdaterArr[Plugins].Hooks[SUCCESS_UPDATE] := @SuccessPlugins;
end;
2010-04-16 10:08:41 -04:00
if (AddUpdater('Reflection', 'http://wizzup.org/static/srl/srlref.tar.bz2', 'http://wizzup.org/static/srl/srl_refl_version', IncludePath, True, True, Refl)) then
begin
UpdaterArr[Refl].Hooks[ATTACH_HOOK] := @OpenDefMenu;
end;
2010-04-16 10:08:41 -04:00
end;
function GetName: string;
2010-04-16 10:08:41 -04:00
begin
Result := 'SRL Updater';
2010-04-16 10:08:41 -04:00
end;
function GetVersion: string;
begin
Result := '0.1';
2010-04-16 10:08:41 -04:00
end;
begin
2010-07-15 20:10:01 -04:00
end.