2010-04-16 10:08:41 -04:00
program SRLUpdater;
2011-01-02 17:08:06 -05:00
{.INCLUDE ..\Extensions\Updater.sei}
2010-04-16 10:08:41 -04:00
2011-01-02 17:08:06 -05:00
function CheckSRL(Name: string; I: integer): boolean;
2010-04-16 10:08:41 -04:00
var
2011-01-02 17:08:06 -05:00
X: integer;
2010-04-16 10:08:41 -04:00
begin
2011-01-02 17:08:06 -05:00
Result := True;
for X := 0 to Length(UpdaterArr) do
if (UpdaterArr[X].Name = 'Plugins') then
2010-07-15 20:10:01 -04:00
begin
2011-01-02 17:08:06 -05:00
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;
2011-01-02 17:08:06 -05:00
procedure OpenDefScript(Sender: TObject);
2010-07-15 11:42:48 -04:00
var
2011-01-02 17:08:06 -05:00
Script: TStringArray;
2010-07-15 11:42:48 -04:00
begin
2011-06-09 14:27:32 -04:00
SetLength(Script, 7);
2011-01-02 17:08:06 -05:00
Script[0] := 'program Untitled;';
2011-06-09 14:27:32 -04:00
Script[1] := '{$DEFINE SMART}';
Script[2] := '{$I SRL/SRL.scar}';
if (TMenuItem(Sender).Parent.Caption = 'Reflection') then
begin
SetLength(Script, Length(Script) + 1);
Script[High(Script) - 4] := '{$I Reflection/Reflection.simba}';
end;
Script[High(Script) - 3] := '';
Script[High(Script) - 2] := 'begin';
Script[High(Script) - 1] := ' SetupSRL;';
2011-01-02 17:08:06 -05:00
if (TMenuItem(Sender).Parent.Caption = 'Reflection') then
2010-07-15 11:42:48 -04:00
begin
2011-06-09 14:27:32 -04:00
SetLength(Script, Length(Script) + 1);
Script[High(Script) - 1] := ' SetupReflection;';
2010-07-15 11:42:48 -04:00
end;
2011-06-09 14:27:32 -04:00
Script[High(Script)] := 'end.';
2011-01-02 17:08:06 -05: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;
2011-01-02 17:08:06 -05:00
function OpenDefMenu(const Blank: string; const ID: integer): boolean;
2010-04-16 10:08:41 -04:00
var
2011-01-02 17:08:06 -05:00
OpenMenuItem: TMenuItem;
2010-04-16 10:08:41 -04:00
begin
2011-01-02 17:08:06 -05:00
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;
2011-01-02 17:08:06 -05:00
function BeforePlugins(NotNeeded: string; I: integer): boolean;
2010-04-16 10:08:41 -04:00
begin
2011-01-02 17:08:06 -05:00
Result := ForceDirectories(UpdaterArr[I].Folder);
2010-04-16 10:08:41 -04:00
end;
2010-07-15 20:10:01 -04:00
2011-01-02 17:08:06 -05:00
function SuccessPlugins(Cont: string; I: integer): boolean;
var
X: integer;
Files: TStringArray;
Overwrite: boolean;
2010-04-16 10:08:41 -04:00
begin
2011-01-02 17:08:06 -05:00
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
2011-01-02 17:08:06 -05:00
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;
2011-01-02 17:08:06 -05:00
Result := UnTarEx(Cont, PluginPath, Overwrite);
2010-04-16 10:08:41 -04:00
end;
2011-01-02 17:08:06 -05:00
procedure Init;
var
SRL, Plugins, Refl: integer;
2010-04-16 10:08:41 -04:00
begin
2011-01-02 17:08:06 -05:00
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
2011-01-02 17:08:06 -05: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;
2011-01-02 17:08:06 -05:00
function GetName: string;
2010-04-16 10:08:41 -04:00
begin
2011-01-02 17:08:06 -05:00
Result := 'SRL Updater';
2010-04-16 10:08:41 -04:00
end;
2011-01-02 17:08:06 -05:00
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.