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

Extension: Updater.sei update.

This commit is contained in:
John P (Dgby714) 2011-01-03 03:20:03 -05:00
parent 26e425e27d
commit a48c4e6ec8

View File

@ -12,7 +12,7 @@ type
THookArr = array[ATTACH_HOOK..AFTER_UPDATE] of THookFunc; THookArr = array[ATTACH_HOOK..AFTER_UPDATE] of THookFunc;
TUpdater = record TUpdater = record
Name, URL, VersionURL, Folder: string; Name, URL, VersionURL, Folder: string;
CreateMenu, NoMenuTimer: boolean; CreateMenu, NoMenuTimer, Locked: boolean;
Hooks: THookArr; Hooks: THookArr;
ViewMenuItem: TMenuItem; ViewMenuItem: TMenuItem;
MainMenu, UpdateMenuItem, CheckMenuItem: TMenuItem; MainMenu, UpdateMenuItem, CheckMenuItem: TMenuItem;
@ -24,7 +24,6 @@ type
var var
UpdaterArr: TUpdaterArr; UpdaterArr: TUpdaterArr;
Locked: boolean;
function GetOVersion(Updater: TUpdater): integer; function GetOVersion(Updater: TUpdater): integer;
begin begin
@ -59,14 +58,6 @@ begin
Locked := True; Locked := True;
if (not ((Sender = UpdateMenuItem) or (AUpdateMenuItem.Checked))) then
if (not (MessageDlg(Name + ' Updater', 'Updates are available! Do you wish to Update now?', mtConfirmation, [mbNo, mbYes], 0) = mrYes)) then
begin
Settings.SetKeyValue(Name + '_DontUpdate', 'true');
Locked := False;
Exit;
end;
WriteLn(Name + ' Updater: Local Version - "' + IntToStr(GetLVersion(UpdaterArr[I])) + '" | Remote Version = "' + IntToStr(GetOVersion(UpdaterArr[I])) + '"'); WriteLn(Name + ' Updater: Local Version - "' + IntToStr(GetLVersion(UpdaterArr[I])) + '" | Remote Version = "' + IntToStr(GetOVersion(UpdaterArr[I])) + '"');
WriteLn(Name + ' Updater: Update File - "' + URL + '"'); WriteLn(Name + ' Updater: Update File - "' + URL + '"');
WriteLn(Name + ' Updater: Downloading...'); WriteLn(Name + ' Updater: Downloading...');
@ -108,9 +99,6 @@ var
I: integer; I: integer;
Name: string; Name: string;
begin begin
if (Locked) then
Exit;
for I := 0 to High(UpdaterArr) + 1 do for I := 0 to High(UpdaterArr) + 1 do
if (not (I = High(UpdaterArr) + 1)) then if (not (I = High(UpdaterArr) + 1)) then
begin begin
@ -118,7 +106,7 @@ begin
UpdaterArr[I].Timer: Name := 'Timer'; UpdaterArr[I].Timer: Name := 'Timer';
UpdaterArr[I].CheckMenuItem: begin UpdaterArr[I].CheckMenuItem: begin
Name := 'Check'; Name := 'Check';
Settings.SetKeyValue(Name + '_DontUpdate', 'false'); Settings.SetKeyValue(UpdaterArr[I].Name + '_DontUpdate', 'false');
end; end;
end; end;
if (not (Name = '')) then if (not (Name = '')) then
@ -126,6 +114,9 @@ begin
end else end else
Exit; Exit;
if (UpdaterArr[I].Locked) then
Exit;
if (UpdaterArr[I].Hooks[CHECK_FOR_UPDATE] <> nil) then if (UpdaterArr[I].Hooks[CHECK_FOR_UPDATE] <> nil) then
if (not (UpdaterArr[I].Hooks[CHECK_FOR_UPDATE](Name, I))) then if (not (UpdaterArr[I].Hooks[CHECK_FOR_UPDATE](Name, I))) then
Exit; Exit;
@ -171,12 +162,12 @@ begin
end; end;
end; end;
TimerMenuItem: begin TimerMenuItem: begin
if (InputQuery(Name + ' Updater', 'What would you like the Timer Interval to be? (1000 - 25000)', Value)) then if (InputQuery(Name + ' Updater', 'What would you like the Timer Interval to be? (1 - 100000 seconds)', Value)) then
begin begin
Value := ExtractFromStr(Value, Numbers); Value := ExtractFromStr(Value, Numbers);
if ((IntToStr(StrToIntDef(Value, -1)) = Value) and InRange(StrToIntDef(Value, -1), 1000, 25000)) then if ((IntToStr(StrToIntDef(Value, -1)) = Value) and InRange(StrToIntDef(Value, -1), 1, 100000)) then
begin begin
Timer.Interval := StrToIntDef(Value, Timer.Interval); Timer.Interval := StrToIntDef(Value, (Timer.Interval / 1000)) * 1000;
TimerMenuItem.Caption := 'Timer Interval: ' + IntToStr(Timer.Interval); TimerMenuItem.Caption := 'Timer Interval: ' + IntToStr(Timer.Interval);
Settings.SetKeyValue(Name + '_TimerInterval', IntToStr(Timer.Interval)); Settings.SetKeyValue(Name + '_TimerInterval', IntToStr(Timer.Interval));
end; end;
@ -315,7 +306,7 @@ begin
MainMenu.Add(SettingsMenu); MainMenu.Add(SettingsMenu);
TimerMenuItem := TMenuItem.Create(SettingsMenu); TimerMenuItem := TMenuItem.Create(SettingsMenu);
TimerMenuItem.Caption := 'Timer Interval: ' + ExtractFromStr(Settings.GetKeyValueDef(Name + '_TimerInterval', '10000'), Numbers); TimerMenuItem.Caption := 'Timer Interval: ' + ExtractFromStr(Settings.GetKeyValueDef(Name + '_TimerInterval', '3600000'), Numbers);
TimerMenuItem.OnClick := @Click; TimerMenuItem.OnClick := @Click;
SettingsMenu.Add(TimerMenuItem); SettingsMenu.Add(TimerMenuItem);
@ -327,7 +318,7 @@ begin
end; end;
Timer := TTimer.Create(nil); Timer := TTimer.Create(nil);
Timer.Interval := StrToIntDef(ExtractFromStr(Settings.GetKeyValueDef(Name + '_TimerInterval', '10000'), Numbers), 10000); Timer.Interval := StrToIntDef(ExtractFromStr(Settings.GetKeyValueDef(Name + '_TimerInterval', '3600000'), Numbers), 3600000);
if (ShowMenu) then if (ShowMenu) then
Timer.Enabled := ACheckMenuItem.Checked Timer.Enabled := ACheckMenuItem.Checked
else else