mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-21 08:45:06 -05:00
Kinda completed the backend of ScriptManager, left is GUI and some small adjustments!
This commit is contained in:
parent
e6ee7f378c
commit
48a43fa897
@ -12,10 +12,10 @@ object Form1: TForm1
|
|||||||
object Button1: TButton
|
object Button1: TButton
|
||||||
Left = 16
|
Left = 16
|
||||||
Height = 33
|
Height = 33
|
||||||
Top = 365
|
Top = 384
|
||||||
Width = 680
|
Width = 680
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
Caption = 'Button1'
|
Caption = 'Refresh'
|
||||||
OnClick = Button1Click
|
OnClick = Button1Click
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
@ -52,4 +52,13 @@ object Form1: TForm1
|
|||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
OnChange = ListView1Change
|
OnChange = ListView1Change
|
||||||
end
|
end
|
||||||
|
object Button2: TButton
|
||||||
|
Left = 21
|
||||||
|
Height = 38
|
||||||
|
Top = 338
|
||||||
|
Width = 672
|
||||||
|
Caption = 'Install'
|
||||||
|
OnClick = Button2Click
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -37,7 +37,7 @@ uses
|
|||||||
{$IFDEF UNIX}cthreads,cmem,{$ENDIF} Classes, SysUtils, FileUtil, Forms,
|
{$IFDEF UNIX}cthreads,cmem,{$ENDIF} Classes, SysUtils, FileUtil, Forms,
|
||||||
Controls, Graphics, Dialogs, StdCtrls,
|
Controls, Graphics, Dialogs, StdCtrls,
|
||||||
ExtCtrls, ComCtrls, ActnList, Menus, settings, updater,strutils, MufasaTypes,
|
ExtCtrls, ComCtrls, ActnList, Menus, settings, updater,strutils, MufasaTypes,
|
||||||
dom;
|
dom, mmisc;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ type
|
|||||||
function IsInstalled: boolean;
|
function IsInstalled: boolean;
|
||||||
procedure LoadFromNode( Script : TDOMNode);
|
procedure LoadFromNode( Script : TDOMNode);
|
||||||
public
|
public
|
||||||
Name, Version, Author, Description: String;
|
Name, Version, Author, Description, URL: String;
|
||||||
Tags, Files: TStringList;
|
Tags, Files: TStringList;
|
||||||
LocalScript : TSimbaScript;
|
LocalScript : TSimbaScript;
|
||||||
property Installed : boolean read IsInstalled;
|
property Installed : boolean read IsInstalled;
|
||||||
@ -79,21 +79,21 @@ type
|
|||||||
FLScripts: TList; //Array of the local scripts
|
FLScripts: TList; //Array of the local scripts
|
||||||
FVersion : String;
|
FVersion : String;
|
||||||
FUpdating : boolean;
|
FUpdating : boolean;
|
||||||
function FindScriptByName(name : string) : Integer;
|
|
||||||
function FindLScriptByName(name : string) : Integer;
|
|
||||||
function GetLScriptCount: integer;
|
function GetLScriptCount: integer;
|
||||||
function GetMainDir: string;
|
function GetMainDir: string;
|
||||||
function GetScript(index : integer): TSimbaScript;
|
function GetScript(index : integer): TSimbaScript;
|
||||||
function GetScriptCount: integer;
|
function GetScriptCount: integer;
|
||||||
procedure MatchLocalOnline;
|
procedure MatchLocalOnline;
|
||||||
public
|
public
|
||||||
|
function FindScriptByName(name : string) : Integer;
|
||||||
|
function FindLScriptByName(name : string) : Integer;
|
||||||
property MainDir : string read GetMainDir write FMaindir;
|
property MainDir : string read GetMainDir write FMaindir;
|
||||||
property SimbaScript[index : integer] : TSimbaScript read GetScript;
|
property SimbaScript[index : integer] : TSimbaScript read GetScript;
|
||||||
procedure Update; //Gets the online scripts
|
procedure Update; //Gets the online scripts
|
||||||
procedure LUpdate; //Loads the local scripts, uses MainDir
|
procedure LUpdate; //Loads the local scripts, uses MainDir
|
||||||
function NewVersion(Script : integer) : boolean; //Checks for updates for Script
|
function NewVersion(Script : integer) : boolean; //Checks for updates for Script
|
||||||
procedure InstallNewScript(Script : integer); //Installs Script (Online -> Local)
|
procedure InstallNewScript(Script : integer); //Installs Script (Online -> Local)
|
||||||
procedure UpdateScript(Script : integer; ignoreupdating : boolean = false); //Updates all the info/files of local script
|
function UpdateScript(Script : integer; ignoreupdating : boolean = false) : boolean; //Updates all the info/files of local script
|
||||||
procedure LSave; //Saves the local scripts, uses MainDir
|
procedure LSave; //Saves the local scripts, uses MainDir
|
||||||
property LScriptCount : integer read GetLScriptCount; //LScript = Local Script = Installed Script
|
property LScriptCount : integer read GetLScriptCount; //LScript = Local Script = Installed Script
|
||||||
property ScriptCount : integer read GetScriptCount; //Online script
|
property ScriptCount : integer read GetScriptCount; //Online script
|
||||||
@ -106,10 +106,12 @@ type
|
|||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
Button1: TButton;
|
Button1: TButton;
|
||||||
|
Button2: TButton;
|
||||||
GroupBox1: TGroupBox;
|
GroupBox1: TGroupBox;
|
||||||
ListView1: TListView;
|
ListView1: TListView;
|
||||||
Memo1: TMemo;
|
Memo1: TMemo;
|
||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
|
procedure Button2Click(Sender: TObject);
|
||||||
procedure ClickItem(Sender: TObject; Button: TMouseButton;
|
procedure ClickItem(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
@ -190,6 +192,7 @@ var
|
|||||||
Item : TListItem;
|
Item : TListItem;
|
||||||
begin
|
begin
|
||||||
Mng.Update;
|
Mng.Update;
|
||||||
|
ListView1.Items.Clear;
|
||||||
for i := 0 to Mng.ScriptCount - 1 do
|
for i := 0 to Mng.ScriptCount - 1 do
|
||||||
begin
|
begin
|
||||||
Item := ListView1.Items.Add;
|
Item := ListView1.Items.Add;
|
||||||
@ -198,6 +201,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.Button2Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
Script : TSimbaScript;
|
||||||
|
begin
|
||||||
|
if (ListView1.Selected <> nil) and (ListView1.Selected.Data <> nil) then
|
||||||
|
begin
|
||||||
|
Script := TSimbaScript(ListView1.Selected.Data);
|
||||||
|
Mng.InstallNewScript(mng.FindScriptByName(Script.Name));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSimbaScript }
|
{ TSimbaScript }
|
||||||
|
|
||||||
function TSimbaScript.IsInstalled: boolean;
|
function TSimbaScript.IsInstalled: boolean;
|
||||||
@ -242,6 +256,7 @@ begin
|
|||||||
Description:= NodeContents('Description',script);
|
Description:= NodeContents('Description',script);
|
||||||
Tags := NodeSubContents('Tags',script);
|
Tags := NodeSubContents('Tags',script);
|
||||||
Files := NodeSubContents('Files',script);
|
Files := NodeSubContents('Files',script);
|
||||||
|
URL := 'http://old.villavu.com/sm/scripts/'+Name+'.tar.bz2';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSimbaScript.Dbg;
|
procedure TSimbaScript.Dbg;
|
||||||
@ -459,12 +474,13 @@ begin
|
|||||||
UpdateScript(FLScripts.Count - 1,true);
|
UpdateScript(FLScripts.Count - 1,true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TScriptManager.UpdateScript(Script: integer; ignoreupdating : boolean = false);
|
function TScriptManager.UpdateScript(Script: integer; ignoreupdating : boolean = false) : boolean;
|
||||||
var
|
var
|
||||||
LScrpt : TLSimbaScript;
|
LScrpt : TLSimbaScript;
|
||||||
Scrpt : TSimbaScript;
|
Scrpt : TSimbaScript;
|
||||||
DownloadThread : TDownloadThread;
|
DownloadThread : TDownloadDecompressThread;
|
||||||
begin
|
begin
|
||||||
|
Result := true;
|
||||||
if not NewVersion(Script) then
|
if not NewVersion(Script) then
|
||||||
Exit;
|
Exit;
|
||||||
if FUpdating and not ignoreupdating then
|
if FUpdating and not ignoreupdating then
|
||||||
@ -480,10 +496,19 @@ begin
|
|||||||
Description:= Scrpt.Version;
|
Description:= Scrpt.Version;
|
||||||
Tags.Assign(Scrpt.Tags);
|
Tags.Assign(Scrpt.Tags);
|
||||||
Files.Assign(Scrpt.Files);
|
Files.Assign(Scrpt.Files);
|
||||||
|
URL := 'http://old.villavu.com/sm/scripts/'+name+ '.tar.bz2';
|
||||||
end;
|
end;
|
||||||
LScrpt.Save(MainDir); //Saves the setting file, now we only need to update the files
|
LScrpt.Save(MainDir); //Saves the setting file, now we only need to update the files
|
||||||
//Download files & write to folder
|
DownloadThread := TDownloadDecompressThread.Create(LScrpt.URL,MainDir + LScrpt.Name + DS,true);
|
||||||
|
DownloadThread.execute;
|
||||||
|
while DownloadThread.Done = false do
|
||||||
|
begin
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Sleep(25);
|
||||||
|
end;
|
||||||
|
Result := DownloadThread.Succeeded;
|
||||||
|
DownloadThread.Free;
|
||||||
|
LSave; //Update the scripts XML file
|
||||||
FUPdating := false;
|
FUPdating := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -520,6 +545,8 @@ begin
|
|||||||
FScripts := TList.Create;
|
FScripts := TList.Create;
|
||||||
FVersion := '';
|
FVersion := '';
|
||||||
FUpdating:= False;
|
FUpdating:= False;
|
||||||
|
FMainDir:= ExtractFileDir(Application.ExeName);
|
||||||
|
CreateDir(MainDir + 'General');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TScriptManager.Destroy;
|
destructor TScriptManager.Destroy;
|
||||||
@ -607,6 +634,8 @@ end;
|
|||||||
constructor TLSimbaScript.create;
|
constructor TLSimbaScript.create;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
Tags := TStringList.Create; //Might leak, but careface
|
||||||
|
Files := TStringList.create; //Same ^
|
||||||
AutoCheckUpdates:= true;
|
AutoCheckUpdates:= true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
<CharSet Value="04B0"/>
|
<CharSet Value="04B0"/>
|
||||||
<StringTable ProductVersion=""/>
|
<StringTable ProductVersion=""/>
|
||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
<IgnoreBinaries Value="False"/>
|
||||||
@ -307,8 +310,8 @@
|
|||||||
<Filename Value="../../Simba"/>
|
<Filename Value="../../Simba"/>
|
||||||
</Target>
|
</Target>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)/;$(ProjPath)../../Units/MMLAddon/PSInc/"/>
|
<IncludeFiles Value="$(ProjOutDir);$(ProjPath)../../Units/MMLAddon/PSInc"/>
|
||||||
<OtherUnitFiles Value="$(ProjPath)/;$(ProjPath)../../Units/MMLCore/;$(ProjPath)../../Units/MMLAddon/;$(ProjPath)../../Units/PascalScript/;$(ProjPath)../../Units/Misc/;$(ProjPath)../../Units/MMLAddon/PSInc/;$(ProjPath)../../Units/Linux/;$(ProjPath)../../Units/Synapse/;$(LazarusDir)/components/mouseandkeyinput/;$(ProjPath)../../Units/RUTIS/"/>
|
<OtherUnitFiles Value="$(ProjPath);$(ProjPath)../../Units/MMLCore;$(ProjPath)../../Units/MMLAddon;$(ProjPath)../../Units/PascalScript;$(ProjPath)../../Units/Misc;$(ProjPath)../../Units/MMLAddon/PSInc;$(ProjPath)../../Units/Linux;$(ProjPath)../../Units/Synapse;$(LazarusDir)/components/mouseandkeyinput;$(ProjPath)../../Units/RUTIS"/>
|
||||||
<UnitOutputDirectory Value="$(ProjPath)../../build/$(TargetOS)"/>
|
<UnitOutputDirectory Value="$(ProjPath)../../build/$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Parsing>
|
<Parsing>
|
||||||
|
Loading…
Reference in New Issue
Block a user