Inno Setup DeusEx.ini help needed
Moderators: Master_Kale, TNM Team
Inno Setup DeusEx.ini help needed
I'm trying to create a repack with many DeusEx mods. While Editing DeusEx.ini isn't much of a problem in general, adding new Path keys was quite a headcracker. I'm not particularly keen on Pascal, so I asked around in forums, and people wrote a piece of code for which can do that, but is a little less than satisfactory
As you can see, it adds the keys at the end of the sections, and I would, obviously, prefer them to be after the other Path keys. So can anyone help me with a code that can do that? Thanks in advance.
P.S. I guess the "spoiler" tag doesn't work on this forum...
As you can see, it adds the keys at the end of the sections, and I would, obviously, prefer them to be after the other Path keys. So can anyone help me with a code that can do that? Thanks in advance.
P.S. I guess the "spoiler" tag doesn't work on this forum...
Re: Inno Setup DeusEx.ini help needed
Nevermind, I figured it out. Funny thing, no one even mentioned that I don't need them UNDER the Path keys...
Re: Inno Setup DeusEx.ini help needed
Acutally I considered your reasons to be out of a cosmetic concern.hgdagon wrote:Nevermind, I figured it out. Funny thing, no one even mentioned that I don't need them UNDER the Path keys...
Re: Inno Setup DeusEx.ini help needed
FWIW, in case someone else has a problem (or you're interested), here's what I've been using for the GMDX and HDTP installers (which will probably be open-sourced on final, mainly as a help towards this kind of purpose). Note that while DeusEx.ini is generally compatible with the INI file facilities available through the OS, since Paths is a duplicate key, it doesn't work. But one can use the TStringList equivalent to do it.hgdagon wrote:Nevermind, I figured it out. Funny thing, no one even mentioned that I don't need them UNDER the Path keys...
Code: Select all
procedure CopyGMDXIniFiles;
{ procedure that enters the necessary items in the "Paths" portion of DeusEx.ini for GMDX. The typical INI calls
do not work for the "Paths" portion since duplicate names are not typical INI standard. }
var
sstrings: TStringList;
ndx1, ndx2: integer;
begin
sstrings := TStringList.Create;
try
sstrings.LoadFromFile(ExpandConstant('{app}\gmdx\System\gmdx.ini'));
// system line
ndx1 := sstrings.IndexOf('Paths=..\GMDX\System\*.u'); // locate target line.
if ndx1 > -1 then
sstrings.Delete(ndx1); // if already exists, delete it.
ndx1 := sstrings.IndexOf('Paths=..\System\*.u'); // find systems line - will always exist if DeusEx.ini isn't borked.
if ndx1 > -1 then // if it exists.
begin
ndx2 := sstrings.IndexOf('Paths=..\HDTP\System\*.u'); // look for HDTP system line.
if ndx2 > -1 then
sstrings.Insert(ndx2, 'Paths=..\GMDX\System\*.u') // if found, put the line before HDTP line
else
sstrings.Insert(ndx1, 'Paths=..\GMDX\System\*.u'); // if not, put it after the system line.
end;
{...}
sstrings.SaveToFile(ExpandConstant('{app}\gmdx\System\gmdx.ini'));
finally
sstrings.Free;
end;
end;
Code: Select all
Paths=..\GMDX\System\*.u
Paths=..\HDTP\System\*.u
Paths=..\System\*.u
Code: Select all
Paths=..\GMDX\System\*.u
Paths=..\System\*.u
-
- The Nameless Mod
- Posts: 1312
- Joined: Mon Apr 26, 2004 1:54 am
- Location: Perth, Western Australia
Re: Inno Setup DeusEx.ini help needed
I believe inno setup allows you to package and execute built executables so you could simply write your script in whatever programming language you prefer and then bundle it into the installer to be executed on installation.
Re: Inno Setup DeusEx.ini help needed
Afaik non existing Paths are ignored anyway, so it would be probably save to just always have the HDTP entry. And why do you actually modify the game's ini file instead of supplying a Default.ini to be used when starting GMDX?
Re: Inno Setup DeusEx.ini help needed
It's a safer behavior in terms of not breaking any other things or settings as many of the other mod installers do. For instance, the New Vision installer does this and as a result is one of the banes of my existence re the HDTP installer script.Hanfling wrote:And why do you actually modify the game's ini file instead of supplying a Default.ini to be used when starting GMDX?
Re: Inno Setup DeusEx.ini help needed
@ggrotz
Well, as you mentioned, to help others, who work on projects like this, here's what I got from other communities.
And then I call it like this
Obviously, your code is much shorter, but I like to keep thing separate (I have a bit of concentration problem).
Well, as you mentioned, to help others, who work on projects like this, here's what I got from other communities.
Code: Select all
function FormatPathString(str : String) : String;
var
firstThreeChars : String;
charsAfterFirstThree : String;
tempString : String;
finalString : String;
dividerPosition : Integer;
begin
firstThreeChars := Copy(str, 0, 3); //First copy the first thee character which we want to keep
charsAfterFirstThree := Copy(str,4,Length(str)); //copy the rest of the string into a new variable
dividerPosition := Pos('\', charsAfterFirstThree); //find the position of the following '\'
tempString := Copy(charsAfterFirstThree,dividerPosition+1,Length(charsAfterFirstThree)-dividerPosition); //Take everything after the position of '\' (dividerPosition+1) and copy it into a temporary string
finalString := firstThreeChars+tempString; //put your first three characters and your temporary string together
Result := finalString; //return your final string
end;
procedure AppendKey(const FileName, Section, KeyName, KeyValue: string);
var
S: string;
I: Integer;
CurLine: string;
LineIdx: Integer;
SnFound: Boolean;
Strings: TStringList;
begin
Strings := TStringList.Create;
try
S := Format('[%s]', [Section]);
Strings.LoadFromFile(FileName);
SnFound := False;
LineIdx := Strings.Count;
for I := Strings.Count - 1 downto 0 do
begin
CurLine := Trim(Strings[I]);
// if the iterated line is a section, then...
if (Length(CurLine) > 2) and (CurLine[1] = '[') and (CurLine[Length(CurLine)] = ']') then
begin
// if the iterated line is the section we are looking for, then...
if CompareText(S, CurLine) = 0 then
begin
SnFound := True;
Break;
end;
end
else
if CurLine = 'Paths=' + FormatPathString(KeyValue) then
LineIdx := I;
end;
if not SnFound then
begin
Strings.Add(S);
Strings.Add(Format('%s=%s', [KeyName, KeyValue]));
end
else
Strings.Insert(LineIdx, Format('%s=%s', [KeyName, KeyValue]));
Strings.SaveToFile(FileName);
finally
Strings.Free;
end;
end;
Code: Select all
procedure CurStepChanged(CurStep: TSetupStep);
Begin
if (CurStep=ssDone) and IsComponentSelected('NV') then
begin
AppendKey(ExpandConstant('{app}\System\DeusEx.ini'), 'Core.System', 'Paths', '..\New Vision\Maps\*.dx');
AppendKey(ExpandConstant('{app}\System\DeusEx.ini'), 'Core.System', 'Paths', '..\New Vision\Textures\*.utx');
end;
if (CurStep=ssDone) and IsComponentSelected('HDTP') then
begin
AppendKey(ExpandConstant('{app}\System\DeusEx.ini'), 'Core.System', 'Paths', '..\HDTP\System\*.u');
AppendKey(ExpandConstant('{app}\System\DeusEx.ini'), 'Core.System', 'Paths', '..\HDTP\Textures\*.utx');
end;
if (CurStep=ssDone) and IsComponentSelected('NV') and IsComponentSelected('HDTP') then
begin
AppendKey(ExpandConstant('{app}\System\hdtp.ini'), 'Core.System', 'Paths', '..\New Vision\Maps\*.dx');
AppendKey(ExpandConstant('{app}\System\hdtp.ini'), 'Core.System', 'Paths', '..\New Vision\Textures\*.utx');
end;
End;
-
- The Nameless Mod
- Posts: 1312
- Joined: Mon Apr 26, 2004 1:54 am
- Location: Perth, Western Australia
Re: Inno Setup DeusEx.ini help needed
I'd forgotten how ugly pascal is