mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-23 09:42:20 -05:00
118 lines
3.3 KiB
Plaintext
118 lines
3.3 KiB
Plaintext
program SRLUpdater;
|
|
|
|
{.INCLUDE ..\Extensions\Updater.sei}
|
|
|
|
function CheckSRL(Name: string; I: integer): boolean;
|
|
var
|
|
X: integer;
|
|
begin
|
|
Result := True;
|
|
for X := 0 to Length(UpdaterArr) do
|
|
if (UpdaterArr[X].Name = 'Plugins') then
|
|
begin
|
|
if (Name = 'Check') then
|
|
Tick(UpdaterArr[X].CheckMenuItem)
|
|
else
|
|
Tick(UpdaterArr[X].Timer);
|
|
Exit;
|
|
end;
|
|
end;
|
|
|
|
procedure OpenDefScript(Sender: TObject);
|
|
var
|
|
Script: TStringArray;
|
|
begin
|
|
SetLength(Script, 7);
|
|
Script[0] := 'program Untitled;';
|
|
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;';
|
|
|
|
if (TMenuItem(Sender).Parent.Caption = 'Reflection') then
|
|
begin
|
|
SetLength(Script, Length(Script) + 1);
|
|
Script[High(Script) - 1] := ' SetupReflection;';
|
|
end;
|
|
|
|
Script[High(Script)] := 'end.';
|
|
|
|
WriteLn('Opening ' + TMenuItem(Sender).Parent.Caption + ' Default Script...');
|
|
OpenScript('', Implode({$IFDEF WIN}#13+{$ENDIF}#10, Script), False);
|
|
end;
|
|
|
|
function OpenDefMenu(const Blank: string; const ID: integer): boolean;
|
|
var
|
|
OpenMenuItem: TMenuItem;
|
|
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;
|
|
end;
|
|
|
|
function BeforePlugins(NotNeeded: string; I: integer): boolean;
|
|
begin
|
|
Result := ForceDirectories(UpdaterArr[I].Folder);
|
|
end;
|
|
|
|
function SuccessPlugins(Cont: string; I: integer): boolean;
|
|
var
|
|
X: integer;
|
|
Files: TStringArray;
|
|
Overwrite: boolean;
|
|
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
|
|
begin
|
|
Overwrite := (MessageDlg('SRL Updater', 'Do you want to overwrite the plugins?', mtConfirmation, [mbNo, mbYes], 0) = mrYes);
|
|
Break;
|
|
end;
|
|
|
|
Result := UnTarEx(Cont, PluginPath, Overwrite);
|
|
end;
|
|
|
|
procedure Init;
|
|
var
|
|
SRL, Plugins, Refl: integer;
|
|
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;
|
|
|
|
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;
|
|
end;
|
|
|
|
function GetName: string;
|
|
begin
|
|
Result := 'SRL Updater';
|
|
end;
|
|
|
|
function GetVersion: string;
|
|
begin
|
|
Result := '0.1';
|
|
end;
|
|
|
|
begin
|
|
end.
|