It is currently Thu May 24, 2018 7:25 pm




Post new topic Reply to topic  [ 9 posts ] 
Inno Setup DeusEx.ini help needed 
Author Message
Mole Person

Joined: Wed Jul 29, 2015 3:06 pm
Posts: 5
Post 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
Image
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...


Wed Jul 29, 2015 3:25 pm
Profile
Mole Person

Joined: Wed Jul 29, 2015 3:06 pm
Posts: 5
Post 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...


Fri Jul 31, 2015 8:51 am
Profile
MJ12

Joined: Sun Oct 04, 2009 6:54 pm
Posts: 399
Post Re: Inno Setup DeusEx.ini help needed
hgdagon wrote:
Nevermind, I figured it out. Funny thing, no one even mentioned that I don't need them UNDER the Path keys...

Acutally I considered your reasons to be out of a cosmetic concern.

_________________
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.


Fri Jul 31, 2015 11:01 am
Profile
Silhouette

Joined: Tue Nov 10, 2009 12:55 am
Posts: 722
Post Re: Inno Setup DeusEx.ini help needed
hgdagon wrote:
Nevermind, I figured it out. Funny thing, no one even mentioned that I don't need them UNDER the Path keys...


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.

Code:
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;


Basically, the final result we're looking for is either:

Code:
Paths=..\GMDX\System\*.u
Paths=..\HDTP\System\*.u
Paths=..\System\*.u


or

Code:
Paths=..\GMDX\System\*.u
Paths=..\System\*.u


Depending on whether HDTP is present. The main thing is to make sure the target line is placed before the line in which the resources exists.

_________________
You can find my Deus Ex Loader here. | HDTP Beta 3


Fri Jul 31, 2015 9:28 pm
Profile
The Nameless Mod
The Nameless Mod

Joined: Mon Apr 26, 2004 1:54 am
Posts: 1312
Location: Perth, Western Australia
Post 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.


Tue Aug 04, 2015 5:48 pm
Profile
MJ12

Joined: Sun Oct 04, 2009 6:54 pm
Posts: 399
Post 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?

_________________
I demand my DXE User ID back. Launcher for DeusEx, Rune, Nerf, Unreal & Botpack. HX on Mod DB. Revision on Steam.


Wed Aug 05, 2015 1:47 am
Profile
Silhouette

Joined: Tue Nov 10, 2009 12:55 am
Posts: 722
Post Re: Inno Setup DeusEx.ini help needed
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?


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.

_________________
You can find my Deus Ex Loader here. | HDTP Beta 3


Wed Aug 05, 2015 11:40 pm
Profile
Mole Person

Joined: Wed Jul 29, 2015 3:06 pm
Posts: 5
Post 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.

Code:
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;


And then I call it like this

Code:
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;


Obviously, your code is much shorter, but I like to keep thing separate (I have a bit of concentration problem).


Sat Aug 08, 2015 5:13 pm
Profile
The Nameless Mod
The Nameless Mod

Joined: Mon Apr 26, 2004 1:54 am
Posts: 1312
Location: Perth, Western Australia
Post Re: Inno Setup DeusEx.ini help needed
I'd forgotten how ugly pascal is


Thu Aug 13, 2015 1:06 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forum/DivisionCore.