mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-11-29 11:24:19 +01:00
added dynamic version feature
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40313
This commit is contained in:
parent
f72855262b
commit
1383a414d8
@ -7,6 +7,7 @@ uses
|
||||
|
||||
var eStream: TMemoryStream;
|
||||
eFiles: TStringList;
|
||||
Version: String;
|
||||
begin
|
||||
WriteLn('// File attacher for the MM:S installer');
|
||||
WriteLn('// by Basic-Master');
|
||||
@ -41,6 +42,14 @@ begin
|
||||
ReadLn;
|
||||
exit;
|
||||
end;
|
||||
{ Get version number }
|
||||
WriteLn('// Please enter the version number:');
|
||||
ReadLn(Version);
|
||||
if (Trim(Version) = '') then begin
|
||||
WriteLn('// Error: Invalid version number!');
|
||||
ReadLn;
|
||||
exit;
|
||||
end;
|
||||
{ Compress files }
|
||||
WriteLn('// Compressing files...');
|
||||
eFiles := TStringList.Create;
|
||||
@ -51,7 +60,7 @@ begin
|
||||
CompressFiles(eFiles, ExtractFilePath(ParamStr(0)) + 'temp.zip');
|
||||
eStream.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'temp.zip');
|
||||
WriteLn('// Attaching output to MMS_Installer.exe...');
|
||||
AttachToFile(ExtractFilePath(ParamStr(0)) + 'MMS_Installer.exe', eStream);
|
||||
AttachToFile(ExtractFilePath(ParamStr(0)) + 'MMS_Installer.exe', eStream, Version);
|
||||
DeleteFile(ExtractFilePath(ParamStr(0)) + 'temp.zip');
|
||||
eStream.Free;
|
||||
WriteLn('// Done.');
|
||||
|
Binary file not shown.
@ -26,6 +26,7 @@ begin
|
||||
Application.Initialize;
|
||||
Application.Title := 'Metamod:Source Installer';
|
||||
Application.CreateForm(TfrmMain, frmMain);
|
||||
UnitfrmMain.VERSION := GetVersion;
|
||||
frmMain.lblWelcome.Caption := 'Welcome to the Metamod:Source ' + VERSION + ' Setup Wizard';
|
||||
frmMain.lblInfo1.Caption := 'This wizard will guide you through the installation of Metamod:Source ' + VERSION + '.';
|
||||
frmMain.lblSubTitle1.Caption := 'Please review the following license terms before installing Metamod:Source ' + VERSION + '.';
|
||||
|
Binary file not shown.
@ -6,12 +6,15 @@ uses SysUtils, Classes, Zlib;
|
||||
|
||||
procedure CompressFiles(Files : TStrings; const Filename : String);
|
||||
function DecompressStream(Stream : TMemoryStream; DestDirectory : String): Boolean;
|
||||
function AttachToFile(const AFileName: string; MemoryStream: TMemoryStream): Boolean;
|
||||
function AttachToFile(const AFileName: string; MemoryStream: TMemoryStream; Version: String): Boolean;
|
||||
function LoadFromFile(const AFileName: string; MemoryStream: TMemoryStream): Boolean;
|
||||
function Unpack: Boolean;
|
||||
function GetVersion: String;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitfrmMain;
|
||||
|
||||
procedure CompressFiles(Files : TStrings; const Filename : String);
|
||||
var
|
||||
infile, outfile, tmpFile : TFileStream;
|
||||
@ -103,7 +106,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function AttachToFile(const AFileName: string; MemoryStream: TMemoryStream): Boolean;
|
||||
function AttachToFile(const AFileName: string; MemoryStream: TMemoryStream; Version: String): Boolean;
|
||||
var
|
||||
aStream: TFileStream;
|
||||
iSize: Integer;
|
||||
@ -124,6 +127,10 @@ begin
|
||||
// die Streamgröße speichern
|
||||
iSize := MemoryStream.Size + SizeOf(Integer);
|
||||
aStream.Write(iSize, SizeOf(iSize));
|
||||
// save version number+length
|
||||
iSize := aStream.Position;
|
||||
aStream.Write(Version[1], Length(Version));
|
||||
aStream.Write(iSize, SizeOf(iSize));
|
||||
finally
|
||||
aStream.Free;
|
||||
end;
|
||||
@ -132,15 +139,21 @@ end;
|
||||
|
||||
function LoadFromFile(const AFileName: string; MemoryStream: TMemoryStream): Boolean;
|
||||
var
|
||||
aStream: TFileStream;
|
||||
aStream: TMemoryStream;
|
||||
iSize: Integer;
|
||||
EndPos: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
if not FileExists(AFileName) then
|
||||
Exit;
|
||||
|
||||
try
|
||||
aStream := TFileStream.Create(AFileName, fmOpenRead or fmShareDenyWrite);
|
||||
aStream := TMemoryStream.Create;
|
||||
aStream.LoadFromFile(AFileName);
|
||||
// drop version part
|
||||
aStream.Seek(-SizeOf(Integer), soFromEnd);
|
||||
aStream.Read(EndPos, SizeOf(Integer));
|
||||
aStream.SetSize(EndPos);
|
||||
// seek to position where Stream-Size is saved
|
||||
// zur Position seeken wo Streamgröße gespeichert
|
||||
aStream.Seek(-SizeOf(Integer), soFromEnd);
|
||||
@ -169,7 +182,8 @@ var eStream: TMemoryStream;
|
||||
begin
|
||||
eStream := TMemoryStream.Create;
|
||||
try
|
||||
LoadFromFile(ParamStr(0), eStream); // Get ZIP
|
||||
// Get ZIP
|
||||
LoadFromFile(ParamStr(0), eStream);
|
||||
DecompressStream(eStream, ExtractFilePath(ParamStr(0))); // Unpack files
|
||||
|
||||
Result := True;
|
||||
@ -179,4 +193,19 @@ begin
|
||||
eStream.Free;
|
||||
end;
|
||||
|
||||
function GetVersion: String;
|
||||
var FileStream: TFileStream;
|
||||
EndPos, Size: Integer;
|
||||
Version: String;
|
||||
begin
|
||||
FileStream := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyWrite);
|
||||
FileStream.Seek(-SizeOf(Integer), soFromEnd);
|
||||
FileStream.Read(EndPos, SizeOf(EndPos));
|
||||
FileStream.Position := EndPos;
|
||||
Size := FileStream.Size - EndPos - SizeOf(Integer);
|
||||
SetString(Result, nil, Size);
|
||||
FileStream.Read(Pointer(Result)^, Size); // YAMS
|
||||
FileStream.Free;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -68,7 +68,7 @@ object frmMain: TfrmMain
|
||||
Top = 0
|
||||
Width = 527
|
||||
Height = 314
|
||||
ActivePage = jspLicense
|
||||
ActivePage = jspWelcome
|
||||
PropagateEnable = False
|
||||
Align = alClient
|
||||
OnChange = jplWizardChange
|
||||
|
@ -132,7 +132,7 @@ type
|
||||
var
|
||||
frmMain: TfrmMain;
|
||||
|
||||
var VERSION: String = '1.3d';
|
||||
var VERSION: String = '<none>';
|
||||
|
||||
implementation
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user